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/2016/dev_r6393_NOC_WAD/NEMOGCM/NEMO/OPA_SRC/DOM – NEMO

source: branches/2016/dev_r6393_NOC_WAD/NEMOGCM/NEMO/OPA_SRC/DOM/istate.F90 @ 6986

Last change on this file since 6986 was 6986, checked in by acc, 8 years ago

Branch dev_r6393_NOC_WAD. Introduced some WAD test cases, tidied and corrected WAD code

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