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.
istate.F90 in trunk/NEMO/OPA_SRC – NEMO

source: trunk/NEMO/OPA_SRC/istate.F90 @ 359

Last change on this file since 359 was 359, checked in by opalod, 18 years ago

nemo_v1_update_033 : RB + CT : Add new surface pressure gradient algorithms

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 24.8 KB
Line 
1MODULE istate
2   !!======================================================================
3   !!                     ***  MODULE  istate  ***
4   !! Ocean state   :  initial state setting
5   !!=====================================================================
6
7   !!----------------------------------------------------------------------
8   !!   istate_init   : initial state setting
9   !!   istate_tem    : analytical profile for initial Temperature
10   !!   istate_sal    : analytical profile for initial Salinity
11   !!   istate_eel    : initial state setting of EEL R5 configuration
12   !!   istate_gyre   : initial state setting of GYRE configuration
13   !!   istate_uvg    : initial velocity in geostropic balance
14   !!----------------------------------------------------------------------
15   !! * Modules used
16   USE oce             ! ocean dynamics and active tracers
17   USE dom_oce         ! ocean space and time domain
18   USE daymod          !
19   USE ldftra_oce      ! ocean active tracers: lateral physics
20   USE zdf_oce         ! ocean vertical physics
21   USE in_out_manager  ! I/O manager
22   USE phycst          ! physical constants
23   USE wzvmod          ! verctical velocity               (wzv     routine)
24   USE dtatem          ! temperature data                 (dta_tem routine)
25   USE dtasal          ! salinity data                    (dta_sal routine)
26   USE restart         ! ocean restart                   (rst_read routine)
27   USE solisl          ! ???
28
29   IMPLICIT NONE
30   PRIVATE
31
32   !! * Routine accessibility
33   PUBLIC istate_init   ! routine called by step.F90
34
35   !! * Substitutions
36#  include "domzgr_substitute.h90"
37#  include "vectopt_loop_substitute.h90"
38   !!----------------------------------------------------------------------
39   !!   OPA 9.0 , LOCEAN-IPSL (2005)
40   !! $Header$
41   !! This software is governed by the CeCILL licence see modipsl/doc/NEMO_CeCILL.txt
42   !!----------------------------------------------------------------------
43
44CONTAINS
45
46   SUBROUTINE istate_init
47      !!----------------------------------------------------------------------
48      !!                   ***  ROUTINE istate_init  ***
49      !!
50      !! ** Purpose :   Initialization of the dynamics and tracers.
51      !!
52      !! ** Method  :
53      !!
54      !! History :
55      !!   4.0  !  91-03  ()  Original code
56      !!        !  91-11  (G. Madec)
57      !!   9.0  !  03-09  (G. Madec)  F90: Free form, modules, orthogonality
58      !!----------------------------------------------------------------------
59      !! * Local declarations
60      !!----------------------------------------------------------------------
61
62
63      ! Initialization to zero
64      ! ----------------------
65
66      !     before fields       !       now fields        !      after fields       !
67      ;   ub   (:,:,:) = 0.e0   ;   un   (:,:,:) = 0.e0   ;   ua   (:,:,:) = 0.e0
68      ;   vb   (:,:,:) = 0.e0   ;   vn   (:,:,:) = 0.e0   ;   va   (:,:,:) = 0.e0
69      ;                         ;   wn   (:,:,:) = 0.e0   ;
70      ;   rotb (:,:,:) = 0.e0   ;   rotn (:,:,:) = 0.e0   ;
71      ;   hdivb(:,:,:) = 0.e0   ;   hdivn(:,:,:) = 0.e0   ;
72
73      ;   tb   (:,:,:) = 0.e0   ;   tn   (:,:,:) = 0.e0   ;   ta   (:,:,:) = 0.e0
74      ;   sb   (:,:,:) = 0.e0   ;   sn   (:,:,:) = 0.e0   ;   sa   (:,:,:) = 0.e0
75
76      rhd  (:,:,:) = 0.e0
77      rhop (:,:,:) = 0.e0
78      rn2  (:,:,:) = 0.e0 
79
80#if defined key_dynspg_rl
81      ! rigid-lid formulation
82      bsfb(:,:) = 0.e0      ! before barotropic stream-function
83      bsfn(:,:) = 0.e0      ! now    barotropic stream-function
84      bsfd(:,:) = 0.e0      ! barotropic stream-function trend
85#endif
86      ! free surface formulation
87      sshb(:,:) = 0.e0      ! before sea-surface height
88      sshn(:,:) = 0.e0      ! now    sea-surface height
89
90
91      IF( ln_rstart ) THEN                    ! Restart from a file
92         !                                    ! -------------------
93         neuler = 1                              ! Set time-step indicator at nit000 (leap-frog)
94         CALL rst_read                           ! Read the restart file
95      ELSE
96         !                                    ! Start from rest
97         !                                    ! ---------------
98         neuler = 0                              ! Set time-step indicator at nit000 (euler forward)
99         adatrj = 0._wp
100         IF( cp_cfg == 'eel' ) THEN
101            CALL istate_eel                      ! EEL   configuration : start from pre-defined
102            !                                    !                       velocity and thermohaline fields
103         ELSEIF(  cp_cfg == 'gyre') THEN         
104            CALL istate_gyre                     ! GYRE  configuration : start from pre-defined temperature
105            !                                    !                       and salinity fields
106         ELSE
107         !                                       ! Other configurations: Initial temperature and salinity fields
108#if defined key_dtatem
109            CALL dta_tem( nit000 )                  ! read 3D temperature data
110            tb(:,:,:) = t_dta(:,:,:)                ! use temperature data read
111            tn(:,:,:) = t_dta(:,:,:)
112#else
113            IF(lwp) WRITE(numout,*)                 ! analytical temperature profile
114            IF(lwp) WRITE(numout,*)' Temperature initialization using an analytic profile'
115            CALL istate_tem
116#endif
117#if defined key_dtasal
118            CALL dta_sal( nit000 )                  ! read 3D salinity data
119            sb(:,:,:) = s_dta(:,:,:)                ! use salinity data read
120            sn(:,:,:) = s_dta(:,:,:)
121#else
122            ! No salinity data
123            IF(lwp)WRITE(numout,*)                  ! analytical salinity profile
124            IF(lwp)WRITE(numout,*)' Salinity initialisation using a constant value'
125            CALL istate_sal
126#endif
127         ENDIF
128
129      ENDIF
130      !                                       ! Vertical velocity
131      !                                       ! -----------------
132      CALL wzv( nit000 )                         ! from horizontal divergence
133
134   END SUBROUTINE istate_init
135
136
137   SUBROUTINE istate_tem
138      !!---------------------------------------------------------------------
139      !!                  ***  ROUTINE istate_tem  ***
140      !!   
141      !! ** Purpose :   Intialization of the temperature field with an
142      !!      analytical profile or a file (i.e. in EEL configuration)
143      !!
144      !! ** Method  :   Use Philander analytic profile of temperature
145      !!
146      !! References :  Philander ???
147      !!
148      !! History :
149      !!   4.0  !  89-12  (P. Andrich)  Original code
150      !!   6.0  !  96-01  (G. Madec)  terrain following coordinates
151      !!   9.0  !  02-09  (G. Madec)  F90: Free form
152      !!----------------------------------------------------------------------
153      !! * Local declarations
154      INTEGER :: ji, jj, jk
155      !!----------------------------------------------------------------------
156
157      IF(lwp) WRITE(numout,*)
158      IF(lwp) WRITE(numout,*) 'istate_tem : initial temperature profile'
159      IF(lwp) WRITE(numout,*) '~~~~~~~~~~'
160
161      DO jk = 1, jpk
162         DO jj = 1, jpj
163            DO ji = 1, jpi
164               tn(ji,jj,jk) = (  ( ( 7.5 - 0.*ABS(gphit(ji,jj))/30. )   &
165                  &               *( 1.-TANH((fsdept(ji,jj,jk)-80.)/30.) )   &
166                  &            + 10.*(5000.-fsdept(ji,jj,jk))/5000.)  ) * tmask(ji,jj,jk)
167               tb(ji,jj,jk) = tn(ji,jj,jk)
168          END DO
169        END DO
170      END DO
171
172      IF(lwp) CALL prizre( tn    , jpi   , jpj   , jpk   , jpj/2 ,   &
173         &                 1     , jpi   , 5     , 1     , jpk   ,   &
174         &                 1     , 1.    , numout                  )
175
176   END SUBROUTINE istate_tem
177
178
179   SUBROUTINE istate_sal
180      !!---------------------------------------------------------------------
181      !!                  ***  ROUTINE istate_sal  ***
182      !!
183      !! ** Purpose :   Intialize the salinity field with an analytic profile
184      !!
185      !! ** Method  :   Use to a constant value 35.5
186      !!             
187      !! ** Action  :   Initialize sn and sb
188      !!
189      !! History :
190      !!   4.0  !  89-12  (P. Andrich)  Original code
191      !!   8.5  !  02-09  (G. Madec)  F90: Free form
192      !!----------------------------------------------------------------------
193      !! * Local declarations
194      REAL(wp) ::   zsal = 35.50_wp
195      !!----------------------------------------------------------------------
196
197      IF(lwp) WRITE(numout,*)
198      IF(lwp) WRITE(numout,*) 'istate_sal : initial salinity : ', zsal
199      IF(lwp) WRITE(numout,*) '~~~~~~~~~~'
200
201      sn(:,:,:) = zsal * tmask(:,:,:)
202      sb(:,:,:) = sn(:,:,:)
203     
204   END SUBROUTINE istate_sal
205
206
207   SUBROUTINE istate_eel
208      !!----------------------------------------------------------------------
209      !!                   ***  ROUTINE istate_eel  ***
210      !!
211      !! ** Purpose :   Initialization of the dynamics and tracers for EEL R5
212      !!      configuration (channel with or without a topographic bump)
213      !!
214      !! ** Method  : - set temprature field
215      !!              - set salinity field
216      !!              - set velocity field including horizontal divergence
217      !!                and relative vorticity fields
218      !!
219      !! History :
220      !!   8.0  !  01-09  (M. Levy, M. Ben Jelloul)  read file for EEL 2 & 6
221      !!   9.0  !  03-09  (G. Madec, C. Talandier)  EEL 5
222      !!   9.0  !  05-11  (V. Garnier) Surface pressure gradient organization
223      !!----------------------------------------------------------------------
224      !! * Modules used
225      USE eosbn2     ! eq. of state, Brunt Vaisala frequency (eos     routine)
226      USE divcur     ! hor. divergence & rel. vorticity      (div_cur routine)
227      USE ioipsl
228 
229      !! * Local declarations
230      LOGICAL :: llog
231      CHARACTER (len=21) ::   &
232         clname = 'eel.initemp',   &  ! filename (for EEL R2 or R6)
233         clvar  = 'initemp'           ! variable name
234      INTEGER  ::   inum              ! temporary logical unit
235      INTEGER  ::   ji, jj, jk        ! dummy loop indices
236      INTEGER  ::   ilev, itime       ! temporary integers
237      REAL(wp) ::   &
238         zh1, zh2, zslope, zcst       ! temporary scalars
239      REAL(wp) ::   &
240         zt1  = 12._wp,            &  ! surface temperature value (EEL R5)
241         zt2  =  2._wp,            &  ! bottom  temperature value (EEL R5)
242         zsal = 35.5_wp                ! constant salinity (EEL R2, R5 and R6)
243      REAL(wp) ::   &
244         zdt,  zdate0                 ! temporary scalars
245      REAL(wp), DIMENSION(jpk) ::  &
246         zdept                        ! temporary workspace
247      REAL(wp), DIMENSION(jpiglo,jpjglo) ::   &
248         zlamt, zphit                 ! temporary workspace
249# if ! defined key_dynspg_rl
250      REAL(wp), DIMENSION(jpiglo,jpjglo) ::   &
251         zssh                         ! initial ssh over the global domain
252# endif
253      !!----------------------------------------------------------------------
254
255      SELECT CASE ( jp_cfg ) 
256         !                                              ! ====================
257         CASE ( 5 )                                     ! EEL R5 configuration
258            !                                           ! ====================
259
260            ! set temperature field with a linear profile
261            ! -------------------------------------------
262            IF(lwp) WRITE(numout,*)
263            IF(lwp) WRITE(numout,*) 'istate_eel : EEL R5: linear temperature profile'
264            IF(lwp) WRITE(numout,*) '~~~~~~~~~~'
265
266            zh1 = gdept(  1  )
267            zh2 = gdept(jpkm1)
268
269            zslope = ( zt1 - zt2 ) / ( zh1 - zh2 )
270            zcst   = ( zt1 * ( zh1 - zh2) - ( zt1 - zt2 ) * zh1 ) / ( zh1 - zh2 )
271
272            DO jk = 1, jpk
273               tn(:,:,jk) = ( zslope * fsdept(:,:,jk) + zcst  ) * tmask(:,:,jk)
274               tb(:,:,jk) = tn(:,:,jk)
275            END DO
276
277            IF(lwp) CALL prizre( tn    , jpi   , jpj   , jpk   , jpj/2 ,   &
278               &                 1     , jpi   , 5     , 1     , jpk   ,   &
279               &                 1     , 1.    , numout                  )
280
281            ! set salinity field to a constant value
282            ! --------------------------------------
283            IF(lwp) WRITE(numout,*)
284            IF(lwp) WRITE(numout,*) 'istate_eel : EEL R5: constant salinity field, S = ', zsal
285            IF(lwp) WRITE(numout,*) '~~~~~~~~~~'
286
287            sn(:,:,:) = zsal * tmask(:,:,:)
288            sb(:,:,:) = sn(:,:,:)
289     
290
291# if ! defined key_dynspg_rl
292            ! set the dynamics: U,V, hdiv, rot (and ssh if necessary)
293            ! ----------------
294            ! Start EEL5 configuration with barotropic geostrophic velocities
295            ! according the sshb and sshn SSH imposed.
296            ub(:,:,:) = 0.1 * umask(:,:,:)
297            un(:,:,:) = ub(:,:,:)
298
299            DO jj = 1, jpjglo
300               zssh(:,jj) = ( .22 - ( FLOAT(jj-3) * (0.44) ) / 99. )
301            END DO
302            DO jj = 1, nlcj
303               DO ji = 1, nlci
304                  sshb(ji,jj) = zssh( mig(ji) , mjg(jj) ) * tmask(ji,jj,1)
305               END DO
306            END DO
307            sshb(nlci+1:jpi,      :   ) = 0.e0      ! set to zero extra mpp columns
308            sshb(      :   ,nlcj+1:jpj) = 0.e0      ! set to zero extra mpp rows
309
310            sshn(:,:) = sshb(:,:)                   ! set now ssh to the before value
311
312            ! horizontal divergence and relative vorticity (curl)
313            CALL div_cur( nit000 )
314
315            ! N.B. the vertical velocity will be computed from the horizontal divergence field
316            ! in istate by a call to wzv routine
317# endif
318
319
320            !                                     ! ==========================
321         CASE ( 2 , 6 )                           ! EEL R2 or R6 configuration
322            !                                     ! ==========================
323 
324            ! set temperature field with a NetCDF file
325            ! ----------------------------------------
326            IF(lwp) WRITE(numout,*)
327            IF(lwp) WRITE(numout,*) 'istate_eel : EEL R2 or R6: read initial temperature in a NetCDF file'
328            IF(lwp) WRITE(numout,*) '~~~~~~~~~~'
329
330            itime  = 0
331            clname = 'eel.initemp'
332            llog   = .FALSE.
333            ilev   = jpk
334            zlamt(:,:) = 0.e0
335            zphit(:,:) = 0.e0
336            CALL restini( clname, jpidta, jpjdta, zlamt , zphit ,   &
337               &          ilev  , zdept , clname, itime , zdate0,   &
338               &          zdt   , inum  , domain_id=nidom )
339            CALL restget( inum  , 'initemp', jpi, jpj, jpk,   &
340               &          0     , llog     , tb             )     ! read before temprature (tb)
341            CALL restclo( inum )
342 
343            tn(:,:,:) = tb(:,:,:)                                 ! set nox temperature to tb
344
345            IF(lwp) WRITE(numout,*) '               file name : ', clname
346            IF(lwp) CALL prizre( tn    , jpi   , jpj   , jpk   , jpj/2 ,   &
347               &                 1     , jpi   , 5     , 1     , jpk   ,   &
348               &                 1     , 1.    , numout                  )
349
350
351            ! set salinity field to a constant value
352            ! --------------------------------------
353            IF(lwp) WRITE(numout,*)
354            IF(lwp) WRITE(numout,*) 'istate_eel : EEL R5: constant salinity field, S = ', zsal
355            IF(lwp) WRITE(numout,*) '~~~~~~~~~~'
356 
357            sn(:,:,:) = zsal * tmask(:,:,:)
358            sb(:,:,:) = sn(:,:,:)
359
360
361            IF( lk_isl ) THEN
362               ! Horizontal velocity : start from geostrophy (EEL config)
363               CALL eos( tn, sn, rhd )     ! now in situ density
364               CALL istate_uvg             ! compute geostrophic velocity
365
366               ! N.B. the vertical velocity will be computed from the horizontal divergence field
367               ! in istate by a call to wzv routine
368            ENDIF
369            !                                    ! ===========================
370         CASE DEFAULT                            ! NONE existing configuration
371            !                                    ! ===========================
372            IF(lwp) WRITE(numout,cform_err) 
373            IF(lwp) WRITE(numout,*) 'EEL with a ', jp_cfg,' km resolution is not coded'
374            nstop = nstop +1
375      END SELECT
376
377   END SUBROUTINE istate_eel
378
379
380   SUBROUTINE istate_gyre
381      !!----------------------------------------------------------------------
382      !!                   ***  ROUTINE istate_gyre  ***
383      !!
384      !! ** Purpose :   Initialization of the dynamics and tracers for GYRE
385      !!      configuration (double gyre with rotated domain)
386      !!
387      !! ** Method  : - set temprature field
388      !!              - set salinity field
389      !!
390      !! ** History :                                     
391      !!      9.0  !  04-05  (A. Koch-Larrouy)  Original code
392      !!----------------------------------------------------------------------
393      !! * Local variables
394      INTEGER :: ji, jj, jk     ! dummy loop indices
395      !!----------------------------------------------------------------------
396
397      IF(lwp) WRITE(numout,*)
398      IF(lwp) WRITE(numout,*) 'istate_gyre : initial analytical T and S profil deduced from LEVITUS '
399      IF(lwp) WRITE(numout,*) '~~~~~~~~~~~'
400
401      DO jk = 1, jpk
402         DO jj = 1, jpj
403            DO ji = 1, jpi
404               tn(ji,jj,jk) = (  16. - 12. * TANH( (fsdept(ji,jj,jk) - 400) / 700 )         )   &
405                    &           * (-TANH( (500-fsdept(ji,jj,jk)) / 150 ) + 1) / 2               &
406                    &       + (      15. * ( 1. - TANH( (fsdept(ji,jj,jk)-50.) / 1500.) )       &
407                    &                - 1.4 * TANH((fsdept(ji,jj,jk)-100.) / 100.)               &   
408                    &                + 7.  * (1500. - fsdept(ji,jj,jk)) / 1500.             )   & 
409                    &           * (-TANH( (fsdept(ji,jj,jk) - 500) / 150) + 1) / 2
410               tn(ji,jj,jk) = tn(ji,jj,jk) * tmask(ji,jj,jk)
411               tb(ji,jj,jk) = tn(ji,jj,jk)
412
413               sn(ji,jj,jk) =  (  36.25 - 1.13 * TANH( (fsdept(ji,jj,jk) - 305) / 460 )  )  &
414                  &              * (-TANH((500 - fsdept(ji,jj,jk)) / 150) + 1) / 2          &
415                  &          + (  35.55 + 1.25 * (5000. - fsdept(ji,jj,jk)) / 5000.         &
416                  &                - 1.62 * TANH( (fsdept(ji,jj,jk) - 60.  ) / 650. )       &
417                  &                + 0.2  * TANH( (fsdept(ji,jj,jk) - 35.  ) / 100. )       &
418                  &                + 0.2  * TANH( (fsdept(ji,jj,jk) - 1000.) / 5000.)    )  &
419                  &              * (-TANH((fsdept(ji,jj,jk) - 500) / 150) + 1) / 2 
420               sn(ji,jj,jk) = sn(ji,jj,jk) * tmask(ji,jj,jk)
421               sb(ji,jj,jk) = sn(ji,jj,jk)
422            END DO
423         END DO
424      END DO
425
426      IF(lwp) THEN
427         WRITE(numout,*)
428         WRITE(numout,*) '              Initial temperature and salinity profiles:'
429         WRITE(numout, "(9x,' level   gdept   temperature   salinity   ')" )
430         WRITE(numout, "(10x, i4, 3f10.2)" ) ( jk, gdept(jk), tn(2,2,jk), sn(2,2,jk), jk = 1, jpk )
431      ENDIF
432
433     
434   END SUBROUTINE istate_gyre
435
436
437
438   SUBROUTINE istate_uvg
439      !!----------------------------------------------------------------------
440      !!                  ***  ROUTINE istate_uvg  ***
441      !!
442      !! ** Purpose :   Compute the geostrophic velocities from (tn,sn) fields
443      !!
444      !! ** Method  :   Using the hydrostatic hypothesis the now hydrostatic
445      !!      pressure is computed by integrating the in-situ density from the
446      !!      surface to the bottom.
447      !!                 p=integral [ rau*g dz ]
448      !!
449      !! History :
450      !!   8.1  !  01-09  (M. Levy, M. Ben Jelloul)  Original code
451      !!   8.5  !  02-09  (G. Madec)  F90: Free form
452      !!   9.0  !  05-11  (V. Garnier) Surface pressure gradient organization
453      !!----------------------------------------------------------------------
454      !! * Modules used
455      USE eosbn2          ! eq. of state, Brunt Vaisala frequency (eos     routine)
456      USE dynspg          ! surface pressure gradient             (dyn_spg routine)
457      USE divcur          ! hor. divergence & rel. vorticity      (div_cur routine)
458      USE lbclnk          ! ocean lateral boundary condition (or mpp link)
459
460      !! * Local declarations
461      INTEGER ::   ji, jj, jk        ! dummy loop indices
462      INTEGER ::   indic             ! ???
463      REAL(wp) ::   &
464         zmsv, zphv, zmsu, zphu,  &  ! temporary scalars
465         zalfg
466      REAL(wp), DIMENSION (jpi,jpj,jpk) ::   &
467         zprn                        ! workspace
468      !!----------------------------------------------------------------------
469
470      IF(lwp) WRITE(numout,*) 
471      IF(lwp) WRITE(numout,*) 'istate_uvg : Start from Geostrophy'
472      IF(lwp) WRITE(numout,*) '~~~~~~~~~~'
473
474      ! Compute the now hydrostatic pressure
475      ! ------------------------------------
476
477      zalfg = 0.5 * grav * rau0
478      ! Surface value
479      zprn(:,:,1) = zalfg * fse3w(:,:,1) * ( 1 + rhd(:,:,1) )
480
481      ! Vertical integration from the surface
482      DO jk = 2, jpkm1
483         zprn(:,:,jk) = zprn(:,:,jk-1)   &
484            &         + zalfg * fse3w(:,:,jk) * ( 2. + rhd(:,:,jk) + rhd(:,:,jk-1) )
485      END DO 
486
487      ! Compute geostrophic balance
488      ! ---------------------------
489
490      DO jk = 1, jpkm1
491         DO jj = 2, jpjm1
492            DO ji = fs_2, fs_jpim1   ! vertor opt.
493               zmsv = 1. / MAX(  umask(ji-1,jj+1,jk) + umask(ji  ,jj+1,jk)   &
494                               + umask(ji-1,jj  ,jk) + umask(ji  ,jj  ,jk) , 1.  )
495               zphv = ( zprn(ji  ,jj+1,jk) - zprn(ji-1,jj+1,jk) ) * umask(ji-1,jj+1,jk) / e1u(ji-1,jj+1)   &
496                    + ( zprn(ji+1,jj+1,jk) - zprn(ji  ,jj+1,jk) ) * umask(ji  ,jj+1,jk) / e1u(ji  ,jj+1)   &
497                    + ( zprn(ji  ,jj  ,jk) - zprn(ji-1,jj  ,jk) ) * umask(ji-1,jj  ,jk) / e1u(ji-1,jj  )   &
498                    + ( zprn(ji+1,jj  ,jk) - zprn(ji  ,jj  ,jk) ) * umask(ji  ,jj  ,jk) / e1u(ji  ,jj  )
499               zphv = 1. / rau0 * zphv * zmsv * vmask(ji,jj,jk)
500
501               zmsu = 1. / MAX(  vmask(ji+1,jj  ,jk) + vmask(ji  ,jj  ,jk)   &
502                               + vmask(ji+1,jj-1,jk) + vmask(ji  ,jj-1,jk) , 1.  )
503               zphu = ( zprn(ji+1,jj+1,jk) - zprn(ji+1,jj  ,jk) ) * vmask(ji+1,jj  ,jk) / e2v(ji+1,jj  )   &
504                    + ( zprn(ji  ,jj+1,jk) - zprn(ji  ,jj  ,jk) ) * vmask(ji  ,jj  ,jk) / e2v(ji  ,jj  )   &
505                    + ( zprn(ji+1,jj  ,jk) - zprn(ji+1,jj-1,jk) ) * vmask(ji+1,jj-1,jk) / e2v(ji+1,jj-1)   &
506                    + ( zprn(ji  ,jj  ,jk) - zprn(ji  ,jj-1,jk) ) * vmask(ji  ,jj-1,jk) / e2v(ji  ,jj-1)
507               zphu = 1. / rau0 * zphu * zmsu * umask(ji,jj,jk)
508
509               ! Compute the geostrophic velocities
510               un(ji,jj,jk) = -2. * zphu / ( ff(ji,jj) + ff(ji  ,jj-1) )
511               vn(ji,jj,jk) =  2. * zphv / ( ff(ji,jj) + ff(ji-1,jj  ) )
512            END DO
513         END DO
514      END DO
515
516      IF(lwp) WRITE(numout,*) '         we force to zero bottom velocity'
517
518      ! Susbtract the bottom velocity (level jpk-1 for flat bottom case)
519      ! to have a zero bottom velocity
520
521      DO jk = 1, jpkm1
522         un(:,:,jk) = ( un(:,:,jk) - un(:,:,jpkm1) ) * umask(:,:,jk)
523         vn(:,:,jk) = ( vn(:,:,jk) - vn(:,:,jpkm1) ) * vmask(:,:,jk)
524      END DO
525
526      CALL lbc_lnk( un, 'U', -1. )
527      CALL lbc_lnk( vn, 'V', -1. )
528     
529      ub(:,:,:) = un(:,:,:)
530      vb(:,:,:) = vn(:,:,:)
531     
532      ! WARNING !!!!!
533      ! after initializing u and v, we need to calculate the initial streamfunction bsf.
534      ! Otherwise, only the trend will be computed and the model will blow up (inconsistency).
535     
536      ! to do that, we call dyn_spg with a special trick:
537      ! we fill ua and va with the velocities divided by dt,
538      ! and the streamfunction will be brought to the right
539      ! value assuming the velocities have been set up in
540      ! one time step.
541      ! we then set bsfd to zero (first guess for next step
542      ! is d(psi)/dt = 0.)
543
544      !  sets up s false trend to calculate the barotropic
545      !  streamfunction.
546
547      ua(:,:,:) = ub(:,:,:) / rdt
548      va(:,:,:) = vb(:,:,:) / rdt
549
550      ! calls dyn_spg. we assume euler time step, starting from rest.
551      indic = 0
552      CALL dyn_spg( nit000, indic )       ! surface pressure gradient
553
554      ! the new velocity is ua*rdt
555
556      CALL lbc_lnk( ua, 'U', -1. )
557      CALL lbc_lnk( va, 'V', -1. )
558
559      ub(:,:,:) = ua(:,:,:) * rdt
560      vb(:,:,:) = va(:,:,:) * rdt
561      ua(:,:,:) = 0.e0
562      va(:,:,:) = 0.e0
563      un(:,:,:) = ub(:,:,:)
564      vn(:,:,:) = vb(:,:,:)
565       
566#if defined key_dynspg_rl
567      IF( lk_isl )   bsfb(:,:) = bsfn(:,:)          ! Put bsfb to zero
568#endif
569
570      ! Compute the divergence and curl
571
572      CALL div_cur( nit000 )            ! now horizontal divergence and curl
573
574      hdivb(:,:,:) = hdivn(:,:,:)       ! set the before to the now value
575      rotb (:,:,:) = rotn (:,:,:)       ! set the before to the now value
576
577   END SUBROUTINE istate_uvg
578
579   !!=====================================================================
580END MODULE istate
Note: See TracBrowser for help on using the repository browser.