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 branches/2015/dev_merge_2015/NEMOGCM/NEMO/OPA_SRC/DOM – NEMO

source: branches/2015/dev_merge_2015/NEMOGCM/NEMO/OPA_SRC/DOM/istate.F90 @ 6060

Last change on this file since 6060 was 6060, checked in by timgraham, 8 years ago

Merged dev_r5836_noc2_VVL_BY_DEFAULT into branch

  • Property svn:keywords set to Id
File size: 24.0 KB
Line 
1MODULE istate
2   !!======================================================================
3   !!                     ***  MODULE  istate  ***
4   !! Ocean state   :  initial state setting
5   !!=====================================================================
6   !! History :  OPA  !  1989-12  (P. Andrich)  Original code
7   !!            5.0  !  1991-11  (G. Madec)  rewritting
8   !!            6.0  !  1996-01  (G. Madec)  terrain following coordinates
9   !!            8.0  !  2001-09  (M. Levy, M. Ben Jelloul)  istate_eel
10   !!            8.0  !  2001-09  (M. Levy, M. Ben Jelloul)  istate_uvg
11   !!   NEMO     1.0  !  2003-08  (G. Madec, C. Talandier)  F90: Free form, modules + EEL R5
12   !!             -   !  2004-05  (A. Koch-Larrouy)  istate_gyre
13   !!            2.0  !  2006-07  (S. Masson)  distributed restart using iom
14   !!            3.3  !  2010-10  (C. Ethe) merge TRC-TRA
15   !!            3.4  !  2011-04  (G. Madec) Merge of dtatem and dtasal & suppression of tb,tn/sb,sn
16   !!----------------------------------------------------------------------
17
18   !!----------------------------------------------------------------------
19   !!   istate_init   : initial state setting
20   !!   istate_tem    : analytical profile for initial Temperature
21   !!   istate_sal    : analytical profile for initial Salinity
22   !!   istate_eel    : initial state setting of EEL R5 configuration
23   !!   istate_gyre   : initial state setting of GYRE configuration
24   !!   istate_uvg    : initial velocity in geostropic balance
25   !!----------------------------------------------------------------------
26   USE oce             ! ocean dynamics and active tracers
27   USE dom_oce         ! ocean space and time domain
28   USE c1d             ! 1D vertical configuration
29   USE daymod          ! calendar
30   USE eosbn2          ! eq. of state, Brunt Vaisala frequency (eos     routine)
31   USE ldftra          ! lateral physics: ocean active tracers
32   USE zdf_oce         ! ocean vertical physics
33   USE phycst          ! physical constants
34   USE dtatsd          ! data temperature and salinity   (dta_tsd routine)
35   USE dtauvd          ! data: U & V current             (dta_uvd routine)
36   USE domvvl          ! varying vertical mesh
37   !
38   USE in_out_manager  ! I/O manager
39   USE iom             ! I/O library
40   USE lib_mpp         ! MPP library
41   USE restart         ! restart
42   USE wrk_nemo        ! Memory allocation
43   USE timing          ! Timing
44
45   IMPLICIT NONE
46   PRIVATE
47
48   PUBLIC   istate_init   ! routine called by step.F90
49
50   !! * Substitutions
51#  include "vectopt_loop_substitute.h90"
52   !!----------------------------------------------------------------------
53   !! NEMO/OPA 3.7 , NEMO Consortium (2014)
54   !! $Id$
55   !! Software governed by the CeCILL licence     (NEMOGCM/NEMO_CeCILL.txt)
56   !!----------------------------------------------------------------------
57CONTAINS
58
59   SUBROUTINE istate_init
60      !!----------------------------------------------------------------------
61      !!                   ***  ROUTINE istate_init  ***
62      !!
63      !! ** Purpose :   Initialization of the dynamics and tracer fields.
64      !!----------------------------------------------------------------------
65      INTEGER ::   ji, jj, jk   ! dummy loop indices
66      REAL(wp), POINTER, DIMENSION(:,:,:,:) ::   zuvd    ! U & V data workspace
67      !!----------------------------------------------------------------------
68      !
69      IF( nn_timing == 1 )   CALL timing_start('istate_init')
70      !
71
72      IF(lwp) WRITE(numout,*)
73      IF(lwp) WRITE(numout,*) 'istate_ini : Initialization of the dynamics and tracers'
74      IF(lwp) WRITE(numout,*) '~~~~~~~~~~'
75
76                     CALL dta_tsd_init        ! Initialisation of T & S input data
77      IF( lk_c1d )   CALL dta_uvd_init        ! Initialization of U & V input data
78
79      rhd  (:,:,:  ) = 0._wp   ;   rhop (:,:,:  ) = 0._wp      ! set one for all to 0 at level jpk
80      rn2b (:,:,:  ) = 0._wp   ;   rn2  (:,:,:  ) = 0._wp      ! set one for all to 0 at levels 1 and jpk
81      tsa  (:,:,:,:) = 0._wp                                   ! set one for all to 0 at level jpk
82      rab_b(:,:,:,:) = 0._wp   ;   rab_n(:,:,:,:) = 0._wp      ! set one for all to 0 at level jpk
83
84      IF( ln_rstart ) THEN                    ! Restart from a file
85         !                                    ! -------------------
86         CALL rst_read                           ! Read the restart file
87         CALL day_init                           ! model calendar (using both namelist and restart infos)
88      ELSE
89         !                                    ! Start from rest
90         !                                    ! ---------------
91         numror = 0                              ! define numror = 0 -> no restart file to read
92         neuler = 0                              ! Set time-step indicator at nit000 (euler forward)
93         CALL day_init                           ! model calendar (using both namelist and restart infos)
94         !                                       ! Initialization of ocean to zero
95         !   before fields      !       now fields     
96         sshb (:,:)   = 0._wp   ;   sshn (:,:)   = 0._wp
97         ub   (:,:,:) = 0._wp   ;   un   (:,:,:) = 0._wp
98         vb   (:,:,:) = 0._wp   ;   vn   (:,:,:) = 0._wp 
99                                    hdivn(:,:,:) = 0._wp
100         !
101         IF( cp_cfg == 'eel' ) THEN
102            CALL istate_eel                      ! EEL   configuration : start from pre-defined U,V T-S fields
103         ELSEIF( cp_cfg == 'gyre' ) THEN         
104            CALL istate_gyre                     ! GYRE  configuration : start from pre-defined T-S fields
105         ELSE                                    ! Initial T-S, U-V fields read in files
106            IF ( ln_tsd_init ) THEN              ! read 3D T and S data at nit000
107               CALL dta_tsd( nit000, tsb ) 
108               tsn(:,:,:,:) = tsb(:,:,:,:)
109               !
110            ELSE                                 ! Initial T-S fields defined analytically
111               CALL istate_t_s
112            ENDIF
113            IF ( ln_uvd_init .AND. lk_c1d ) THEN ! read 3D U and V data at nit000
114               CALL wrk_alloc( jpi,jpj,jpk,2,   zuvd )
115               CALL dta_uvd( nit000, zuvd )
116               ub(:,:,:) = zuvd(:,:,:,1) ;  un(:,:,:) = ub(:,:,:)
117               vb(:,:,:) = zuvd(:,:,:,2) ;  vn(:,:,:) = vb(:,:,:)
118               CALL wrk_dealloc( jpi,jpj,jpk,2,   zuvd )
119            ENDIF
120         ENDIF
121         !
122!!gm This is to be changed !!!!
123         ! - ML - sshn could be modified by istate_eel, so that initialization of e3t_b is done here
124         IF( .NOT.ln_linssh ) THEN
125            DO jk = 1, jpk
126               e3t_b(:,:,jk) = e3t_n(:,:,jk)
127            END DO
128         ENDIF
129!!gm
130         !
131      ENDIF
132      !
133      ! Initialize "now" and "before" barotropic velocities:
134      ! Do it whatever the free surface method, these arrays being eventually used
135      !
136      un_b(:,:) = 0._wp   ;   vn_b(:,:) = 0._wp
137      ub_b(:,:) = 0._wp   ;   vb_b(:,:) = 0._wp
138      !
139!!gm  the use of umsak & vmask is not necessary belox as un, vn, ub, vb are always masked
140      DO jk = 1, jpkm1
141         DO jj = 1, jpj
142            DO ji = 1, jpi
143               un_b(ji,jj) = un_b(ji,jj) + e3u_n(ji,jj,jk) * un(ji,jj,jk) * umask(ji,jj,jk)
144               vn_b(ji,jj) = vn_b(ji,jj) + e3v_n(ji,jj,jk) * vn(ji,jj,jk) * vmask(ji,jj,jk)
145               !
146               ub_b(ji,jj) = ub_b(ji,jj) + e3u_b(ji,jj,jk) * ub(ji,jj,jk) * umask(ji,jj,jk)
147               vb_b(ji,jj) = vb_b(ji,jj) + e3v_b(ji,jj,jk) * vb(ji,jj,jk) * vmask(ji,jj,jk)
148            END DO
149         END DO
150      END DO
151      !
152      un_b(:,:) = un_b(:,:) * r1_hu_n(:,:)
153      vn_b(:,:) = vn_b(:,:) * r1_hv_n(:,:)
154      !
155      ub_b(:,:) = ub_b(:,:) * r1_hu_b(:,:)
156      vb_b(:,:) = vb_b(:,:) * r1_hv_b(:,:)
157      !
158      IF( nn_timing == 1 )   CALL timing_stop('istate_init')
159      !
160   END SUBROUTINE istate_init
161
162
163   SUBROUTINE istate_t_s
164      !!---------------------------------------------------------------------
165      !!                  ***  ROUTINE istate_t_s  ***
166      !!   
167      !! ** Purpose :   Intialization of the temperature field with an
168      !!      analytical profile or a file (i.e. in EEL configuration)
169      !!
170      !! ** Method  : - temperature: use Philander analytic profile
171      !!              - salinity   : use to a constant value 35.5
172      !!
173      !! References :  Philander ???
174      !!----------------------------------------------------------------------
175      INTEGER  ::   ji, jj, jk
176      REAL(wp) ::   zsal = 35.50_wp
177      !!----------------------------------------------------------------------
178      !
179      IF(lwp) WRITE(numout,*)
180      IF(lwp) WRITE(numout,*) 'istate_t_s : Philander s initial temperature profile'
181      IF(lwp) WRITE(numout,*) '~~~~~~~~~~   and constant salinity (',zsal,' psu)'
182      !
183      DO jk = 1, jpk
184         tsn(:,:,jk,jp_tem) = (  ( ( 7.5 - 0. * ABS( gphit(:,:) )/30. ) * ( 1.-TANH((gdept_n(:,:,jk)-80.)/30.) )   &
185            &                + 10. * ( 5000. - gdept_n(:,:,jk) ) /5000.)  ) * tmask(:,:,jk)
186         tsb(:,:,jk,jp_tem) = tsn(:,:,jk,jp_tem)
187      END DO
188      tsn(:,:,:,jp_sal) = zsal * tmask(:,:,:)
189      tsb(:,:,:,jp_sal) = tsn(:,:,:,jp_sal)
190      !
191   END SUBROUTINE istate_t_s
192
193
194   SUBROUTINE istate_eel
195      !!----------------------------------------------------------------------
196      !!                   ***  ROUTINE istate_eel  ***
197      !!
198      !! ** Purpose :   Initialization of the dynamics and tracers for EEL R5
199      !!      configuration (channel with or without a topographic bump)
200      !!
201      !! ** Method  : - set temprature field
202      !!              - set salinity field
203      !!              - set velocity field including horizontal divergence
204      !!                and relative vorticity fields
205      !!----------------------------------------------------------------------
206      USE divhor     ! hor. divergence      (div_hor routine)
207      USE iom
208      !
209      INTEGER  ::   inum              ! temporary logical unit
210      INTEGER  ::   ji, jj, jk        ! dummy loop indices
211      INTEGER  ::   ijloc
212      REAL(wp) ::   zh1, zh2, zslope, zcst, zfcor   ! temporary scalars
213      REAL(wp) ::   zt1  = 15._wp                   ! surface temperature value (EEL R5)
214      REAL(wp) ::   zt2  =  5._wp                   ! bottom  temperature value (EEL R5)
215      REAL(wp) ::   zsal = 35.0_wp                  ! constant salinity (EEL R2, R5 and R6)
216      REAL(wp) ::   zueel = 0.1_wp                  ! constant uniform zonal velocity (EEL R5)
217      REAL(wp), DIMENSION(jpiglo,jpjglo) ::   zssh  ! initial ssh over the global domain
218      !!----------------------------------------------------------------------
219      !
220      SELECT CASE ( jp_cfg ) 
221         !                                              ! ====================
222         CASE ( 5 )                                     ! EEL R5 configuration
223            !                                           ! ====================
224            !
225            ! set temperature field with a linear profile
226            ! -------------------------------------------
227            IF(lwp) WRITE(numout,*)
228            IF(lwp) WRITE(numout,*) 'istate_eel : EEL R5: linear temperature profile'
229            IF(lwp) WRITE(numout,*) '~~~~~~~~~~'
230            !
231            zh1 = gdept_1d(  1  )
232            zh2 = gdept_1d(jpkm1)
233            !
234            zslope = ( zt1 - zt2 ) / ( zh1 - zh2 )
235            zcst   = ( zt1 * ( zh1 - zh2) - ( zt1 - zt2 ) * zh1 ) / ( zh1 - zh2 )
236            !
237            DO jk = 1, jpk
238               tsn(:,:,jk,jp_tem) = ( zt2 + zt1 * exp( - gdept_n(:,:,jk) / 1000 ) ) * tmask(:,:,jk)
239               tsb(:,:,jk,jp_tem) = tsn(:,:,jk,jp_tem)
240            END DO
241            !
242            ! set salinity field to a constant value
243            ! --------------------------------------
244            IF(lwp) WRITE(numout,*)
245            IF(lwp) WRITE(numout,*) 'istate_eel : EEL R5: constant salinity field, S = ', zsal
246            IF(lwp) WRITE(numout,*) '~~~~~~~~~~'
247            !
248            tsn(:,:,:,jp_sal) = zsal * tmask(:,:,:)
249            tsb(:,:,:,jp_sal) = tsn(:,:,:,jp_sal)
250            !
251            ! set the dynamics: U,V, hdiv (and ssh if necessary)
252            ! ----------------
253            ! Start EEL5 configuration with barotropic geostrophic velocities
254            ! according the sshb and sshn SSH imposed.
255            ! we assume a uniform grid (hence the use of e1t(1,1) for delta_y)
256            ! we use the Coriolis frequency at mid-channel.   
257            ub(:,:,:) = zueel * umask(:,:,:)
258            un(:,:,:) = ub(:,:,:)
259            ijloc = mj0(INT(jpjglo-1)/2)
260            zfcor = ff(1,ijloc)
261            !
262            DO jj = 1, jpjglo
263               zssh(:,jj) = - (FLOAT(jj)- FLOAT(jpjglo-1)/2.)*zueel*e1t(1,1)*zfcor/grav 
264            END DO
265            !
266            IF(lwp) THEN
267               WRITE(numout,*) ' Uniform zonal velocity for EEL R5:',zueel
268               WRITE(numout,*) ' Geostrophic SSH profile as a function of y:'
269               WRITE(numout,'(12(1x,f6.2))') zssh(1,:)
270            ENDIF
271            !
272            DO jj = 1, nlcj
273               DO ji = 1, nlci
274                  sshb(ji,jj) = zssh( mig(ji) , mjg(jj) ) * tmask(ji,jj,1)
275               END DO
276            END DO
277            sshb(nlci+1:jpi,      :   ) = 0.e0      ! set to zero extra mpp columns
278            sshb(      :   ,nlcj+1:jpj) = 0.e0      ! set to zero extra mpp rows
279            !
280            sshn(:,:) = sshb(:,:)                   ! set now ssh to the before value
281            !
282            IF( nn_rstssh /= 0 ) THEN 
283               nn_rstssh = 0                        ! hand-made initilization of ssh
284               CALL ctl_warn( 'istate_eel: force nn_rstssh = 0' )
285            ENDIF
286            !
287!!gm  Check  here call to div_hor should not be necessary
288!!gm         div_hor call runoffs  not sure they are defined at that level
289            CALL div_hor( nit000 )                  ! horizontal divergence and relative vorticity (curl)
290            ! N.B. the vertical velocity will be computed from the horizontal divergence field
291            ! in istate by a call to wzv routine
292
293
294            !                                     ! ==========================
295         CASE ( 2 , 6 )                           ! EEL R2 or R6 configuration
296            !                                     ! ==========================
297            !
298            ! set temperature field with a NetCDF file
299            ! ----------------------------------------
300            IF(lwp) WRITE(numout,*)
301            IF(lwp) WRITE(numout,*) 'istate_eel : EEL R2 or R6: read initial temperature in a NetCDF file'
302            IF(lwp) WRITE(numout,*) '~~~~~~~~~~'
303            !
304            CALL iom_open ( 'eel.initemp', inum )
305            CALL iom_get ( inum, jpdom_data, 'initemp', tsb(:,:,:,jp_tem) ) ! read before temprature (tb)
306            CALL iom_close( inum )
307            !
308            tsn(:,:,:,jp_tem) = tsb(:,:,:,jp_tem)                            ! set nox temperature to tb
309            !
310            ! set salinity field to a constant value
311            ! --------------------------------------
312            IF(lwp) WRITE(numout,*)
313            IF(lwp) WRITE(numout,*) 'istate_eel : EEL R5: constant salinity field, S = ', zsal
314            IF(lwp) WRITE(numout,*) '~~~~~~~~~~'
315            !
316            tsn(:,:,:,jp_sal) = zsal * tmask(:,:,:)
317            tsb(:,:,:,jp_sal) = tsn(:,:,:,jp_sal)
318            !
319            !                                    ! ===========================
320         CASE DEFAULT                            ! NONE existing configuration
321            !                                    ! ===========================
322            WRITE(ctmp1,*) 'EEL with a ', jp_cfg,' km resolution is not coded'
323            CALL ctl_stop( ctmp1 )
324            !
325      END SELECT
326      !
327   END SUBROUTINE istate_eel
328
329
330   SUBROUTINE istate_gyre
331      !!----------------------------------------------------------------------
332      !!                   ***  ROUTINE istate_gyre  ***
333      !!
334      !! ** Purpose :   Initialization of the dynamics and tracers for GYRE
335      !!      configuration (double gyre with rotated domain)
336      !!
337      !! ** Method  : - set temprature field
338      !!              - set salinity   field
339      !!----------------------------------------------------------------------
340      INTEGER :: ji, jj, jk  ! dummy loop indices
341      INTEGER            ::   inum          ! temporary logical unit
342      INTEGER, PARAMETER ::   ntsinit = 0   ! (0/1) (analytical/input data files) T&S initialization
343      !!----------------------------------------------------------------------
344      !
345      SELECT CASE ( ntsinit)
346      !
347      CASE ( 0 )                  ! analytical T/S profil deduced from LEVITUS
348         IF(lwp) WRITE(numout,*)
349         IF(lwp) WRITE(numout,*) 'istate_gyre : initial analytical T and S profil deduced from LEVITUS '
350         IF(lwp) WRITE(numout,*) '~~~~~~~~~~~'
351         !
352         DO jk = 1, jpk
353            DO jj = 1, jpj
354               DO ji = 1, jpi
355                  tsn(ji,jj,jk,jp_tem) = (  16. - 12. * TANH( (gdept_n(ji,jj,jk) - 400) / 700 )         )   &
356                       &           * (-TANH( (500-gdept_n(ji,jj,jk)) / 150 ) + 1) / 2               &
357                       &       + (      15. * ( 1. - TANH( (gdept_n(ji,jj,jk)-50.) / 1500.) )       &
358                       &                - 1.4 * TANH((gdept_n(ji,jj,jk)-100.) / 100.)               &   
359                       &                + 7.  * (1500. - gdept_n(ji,jj,jk)) / 1500.             )   & 
360                       &           * (-TANH( (gdept_n(ji,jj,jk) - 500) / 150) + 1) / 2
361                  tsn(ji,jj,jk,jp_tem) = tsn(ji,jj,jk,jp_tem) * tmask(ji,jj,jk)
362                  tsb(ji,jj,jk,jp_tem) = tsn(ji,jj,jk,jp_tem)
363
364                  tsn(ji,jj,jk,jp_sal) =  (  36.25 - 1.13 * TANH( (gdept_n(ji,jj,jk) - 305) / 460 )  )  &
365                     &              * (-TANH((500 - gdept_n(ji,jj,jk)) / 150) + 1) / 2          &
366                     &          + (  35.55 + 1.25 * (5000. - gdept_n(ji,jj,jk)) / 5000.         &
367                     &                - 1.62 * TANH( (gdept_n(ji,jj,jk) - 60.  ) / 650. )       &
368                     &                + 0.2  * TANH( (gdept_n(ji,jj,jk) - 35.  ) / 100. )       &
369                     &                + 0.2  * TANH( (gdept_n(ji,jj,jk) - 1000.) / 5000.)    )  &
370                     &              * (-TANH((gdept_n(ji,jj,jk) - 500) / 150) + 1) / 2 
371                  tsn(ji,jj,jk,jp_sal) = tsn(ji,jj,jk,jp_sal) * tmask(ji,jj,jk)
372                  tsb(ji,jj,jk,jp_sal) = tsn(ji,jj,jk,jp_sal)
373               END DO
374            END DO
375         END DO
376         !
377      CASE ( 1 )                  ! T/S data fields read in dta_tem.nc/data_sal.nc files
378         IF(lwp) WRITE(numout,*)
379         IF(lwp) WRITE(numout,*) 'istate_gyre : initial T and S read from dta_tem.nc/data_sal.nc files'
380         IF(lwp) WRITE(numout,*) '~~~~~~~~~~~'
381         IF(lwp) WRITE(numout,*) '              NetCDF FORMAT'
382
383         ! Read temperature field
384         ! ----------------------
385         CALL iom_open ( 'data_tem', inum )
386         CALL iom_get ( inum, jpdom_data, 'votemper', tsn(:,:,:,jp_tem) ) 
387         CALL iom_close( inum )
388
389         tsn(:,:,:,jp_tem) = tsn(:,:,:,jp_tem) * tmask(:,:,:) 
390         tsb(:,:,:,jp_tem) = tsn(:,:,:,jp_tem)
391
392         ! Read salinity field
393         ! -------------------
394         CALL iom_open ( 'data_sal', inum )
395         CALL iom_get ( inum, jpdom_data, 'vosaline', tsn(:,:,:,jp_sal) ) 
396         CALL iom_close( inum )
397
398         tsn(:,:,:,jp_sal) = tsn(:,:,:,jp_sal) * tmask(:,:,:) 
399         tsb(:,:,:,jp_sal) = tsn(:,:,:,jp_sal)
400         !
401      END SELECT
402      !
403      IF(lwp) THEN
404         WRITE(numout,*)
405         WRITE(numout,*) '              Initial temperature and salinity profiles:'
406         WRITE(numout, "(9x,' level   gdept_1d   temperature   salinity   ')" )
407         WRITE(numout, "(10x, i4, 3f10.2)" ) ( jk, gdept_1d(jk), tsn(2,2,jk,jp_tem), tsn(2,2,jk,jp_sal), jk = 1, jpk )
408      ENDIF
409      !
410   END SUBROUTINE istate_gyre
411
412
413   SUBROUTINE istate_uvg
414      !!----------------------------------------------------------------------
415      !!                  ***  ROUTINE istate_uvg  ***
416      !!
417      !! ** Purpose :   Compute the geostrophic velocities from (tn,sn) fields
418      !!
419      !! ** Method  :   Using the hydrostatic hypothesis the now hydrostatic
420      !!      pressure is computed by integrating the in-situ density from the
421      !!      surface to the bottom.
422      !!                 p=integral [ rau*g dz ]
423      !!----------------------------------------------------------------------
424      USE divhor          ! hor. divergence                       (div_hor routine)
425      USE lbclnk          ! ocean lateral boundary condition (or mpp link)
426      !
427      INTEGER ::   ji, jj, jk        ! dummy loop indices
428      REAL(wp) ::   zmsv, zphv, zmsu, zphu, zalfg     ! temporary scalars
429      REAL(wp), POINTER, DIMENSION(:,:,:) :: zprn
430      !!----------------------------------------------------------------------
431      !
432      CALL wrk_alloc( jpi,jpj,jpk,   zprn)
433      !
434      IF(lwp) WRITE(numout,*) 
435      IF(lwp) WRITE(numout,*) 'istate_uvg : Start from Geostrophy'
436      IF(lwp) WRITE(numout,*) '~~~~~~~~~~'
437
438      ! Compute the now hydrostatic pressure
439      ! ------------------------------------
440
441      zalfg = 0.5 * grav * rau0
442     
443      zprn(:,:,1) = zalfg * e3w_n(:,:,1) * ( 1 + rhd(:,:,1) )       ! Surface value
444
445      DO jk = 2, jpkm1                                              ! Vertical integration from the surface
446         zprn(:,:,jk) = zprn(:,:,jk-1)   &
447            &         + zalfg * e3w_n(:,:,jk) * ( 2. + rhd(:,:,jk) + rhd(:,:,jk-1) )
448      END DO 
449
450      ! Compute geostrophic balance
451      ! ---------------------------
452      DO jk = 1, jpkm1
453         DO jj = 2, jpjm1
454            DO ji = fs_2, fs_jpim1   ! vertor opt.
455               zmsv = 1. / MAX(  umask(ji-1,jj+1,jk) + umask(ji  ,jj+1,jk)   &
456                               + umask(ji-1,jj  ,jk) + umask(ji  ,jj  ,jk) , 1.  )
457               zphv = ( zprn(ji  ,jj+1,jk) - zprn(ji-1,jj+1,jk) ) * umask(ji-1,jj+1,jk) / e1u(ji-1,jj+1)   &
458                    + ( zprn(ji+1,jj+1,jk) - zprn(ji  ,jj+1,jk) ) * umask(ji  ,jj+1,jk) / e1u(ji  ,jj+1)   &
459                    + ( zprn(ji  ,jj  ,jk) - zprn(ji-1,jj  ,jk) ) * umask(ji-1,jj  ,jk) / e1u(ji-1,jj  )   &
460                    + ( zprn(ji+1,jj  ,jk) - zprn(ji  ,jj  ,jk) ) * umask(ji  ,jj  ,jk) / e1u(ji  ,jj  )
461               zphv = 1. / rau0 * zphv * zmsv * vmask(ji,jj,jk)
462
463               zmsu = 1. / MAX(  vmask(ji+1,jj  ,jk) + vmask(ji  ,jj  ,jk)   &
464                               + vmask(ji+1,jj-1,jk) + vmask(ji  ,jj-1,jk) , 1.  )
465               zphu = ( zprn(ji+1,jj+1,jk) - zprn(ji+1,jj  ,jk) ) * vmask(ji+1,jj  ,jk) / e2v(ji+1,jj  )   &
466                    + ( zprn(ji  ,jj+1,jk) - zprn(ji  ,jj  ,jk) ) * vmask(ji  ,jj  ,jk) / e2v(ji  ,jj  )   &
467                    + ( zprn(ji+1,jj  ,jk) - zprn(ji+1,jj-1,jk) ) * vmask(ji+1,jj-1,jk) / e2v(ji+1,jj-1)   &
468                    + ( zprn(ji  ,jj  ,jk) - zprn(ji  ,jj-1,jk) ) * vmask(ji  ,jj-1,jk) / e2v(ji  ,jj-1)
469               zphu = 1. / rau0 * zphu * zmsu * umask(ji,jj,jk)
470
471               ! Compute the geostrophic velocities
472               un(ji,jj,jk) = -2. * zphu / ( ff(ji,jj) + ff(ji  ,jj-1) )
473               vn(ji,jj,jk) =  2. * zphv / ( ff(ji,jj) + ff(ji-1,jj  ) )
474            END DO
475         END DO
476      END DO
477
478      IF(lwp) WRITE(numout,*) '         we force to zero bottom velocity'
479
480      ! Susbtract the bottom velocity (level jpk-1 for flat bottom case)
481      ! to have a zero bottom velocity
482
483      DO jk = 1, jpkm1
484         un(:,:,jk) = ( un(:,:,jk) - un(:,:,jpkm1) ) * umask(:,:,jk)
485         vn(:,:,jk) = ( vn(:,:,jk) - vn(:,:,jpkm1) ) * vmask(:,:,jk)
486      END DO
487
488      CALL lbc_lnk( un, 'U', -1. )
489      CALL lbc_lnk( vn, 'V', -1. )
490     
491      ub(:,:,:) = un(:,:,:)
492      vb(:,:,:) = vn(:,:,:)
493     
494      !
495!!gm  Check  here call to div_hor should not be necessary
496!!gm         div_hor call runoffs  not sure they are defined at that level
497      CALL div_hor( nit000 )            ! now horizontal divergence
498      !
499      CALL wrk_dealloc( jpi,jpj,jpk,   zprn)
500      !
501   END SUBROUTINE istate_uvg
502
503   !!=====================================================================
504END MODULE istate
Note: See TracBrowser for help on using the repository browser.