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 NEMO/branches/2019/dev_r10721_KERNEL-02_Storkey_Coward_IMMERSE_first_steps/src/OCE/DOM – NEMO

source: NEMO/branches/2019/dev_r10721_KERNEL-02_Storkey_Coward_IMMERSE_first_steps/src/OCE/DOM/istate.F90 @ 10978

Last change on this file since 10978 was 10978, checked in by davestorkey, 5 years ago

2019/dev_r10721_KERNEL-02_Storkey_Coward_IMMERSE_first_steps : DOM and sshwzv.F90. (sshwzv.F90 will be rewritten somewhat when we rewrite the time-level swapping but I've done it anyway). Passes all non-AGRIF SETTE tests.

  • Property svn:keywords set to Id
File size: 9.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   !!            3.7  !  2016-04  (S. Flavoni) introduce user defined initial state
17   !!----------------------------------------------------------------------
18
19   !!----------------------------------------------------------------------
20   !!   istate_init   : initial state setting
21   !!   istate_uvg    : initial velocity in geostropic balance
22   !!----------------------------------------------------------------------
23   USE oce            ! ocean dynamics and active tracers
24   USE dom_oce        ! ocean space and time domain
25   USE daymod         ! calendar
26   USE divhor         ! horizontal divergence            (div_hor routine)
27   USE dtatsd         ! data temperature and salinity   (dta_tsd routine)
28   USE dtauvd         ! data: U & V current             (dta_uvd routine)
29   USE domvvl          ! varying vertical mesh
30   USE iscplrst        ! ice sheet coupling
31   USE wet_dry         ! wetting and drying (needed for wad_istate)
32   USE usrdef_istate   ! User defined initial state
33   !
34   USE in_out_manager  ! I/O manager
35   USE iom             ! I/O library
36   USE lib_mpp         ! MPP library
37   USE restart         ! restart
38
39   IMPLICIT NONE
40   PRIVATE
41
42   PUBLIC   istate_init   ! routine called by step.F90
43
44   !! * Substitutions
45#  include "vectopt_loop_substitute.h90"
46   !!----------------------------------------------------------------------
47   !! NEMO/OCE 4.0 , NEMO Consortium (2018)
48   !! $Id$
49   !! Software governed by the CeCILL license (see ./LICENSE)
50   !!----------------------------------------------------------------------
51CONTAINS
52
53   SUBROUTINE istate_init( Kbb, Kmm, Kaa )
54      !!----------------------------------------------------------------------
55      !!                   ***  ROUTINE istate_init  ***
56      !!
57      !! ** Purpose :   Initialization of the dynamics and tracer fields.
58      !!----------------------------------------------------------------------
59      INTEGER, INTENT( in )  ::  Kbb, Kmm, Kaa   ! ocean time level indices
60      !
61      INTEGER ::   ji, jj, jk   ! dummy loop indices
62!!gm see comment further down
63      REAL(wp), ALLOCATABLE, DIMENSION(:,:,:,:) ::   zuvd    ! U & V data workspace
64!!gm end
65      !!----------------------------------------------------------------------
66      !
67      IF(lwp) WRITE(numout,*)
68      IF(lwp) WRITE(numout,*) 'istate_init : Initialization of the dynamics and tracers'
69      IF(lwp) WRITE(numout,*) '~~~~~~~~~~~'
70
71!!gm  Why not include in the first call of dta_tsd ? 
72!!gm  probably associated with the use of internal damping...
73                     CALL dta_tsd_init        ! Initialisation of T & S input data
74!!gm to be moved in usrdef of C1D case
75!      IF( lk_c1d )   CALL dta_uvd_init        ! Initialization of U & V input data
76!!gm
77
78      rhd  (:,:,:  ) = 0._wp   ;   rhop (:,:,:  ) = 0._wp      ! set one for all to 0 at level jpk
79      rn2b (:,:,:  ) = 0._wp   ;   rn2  (:,:,:  ) = 0._wp      ! set one for all to 0 at levels 1 and jpk
80      ts  (:,:,:,:,Kaa) = 0._wp                                   ! set one for all to 0 at level jpk
81      rab_b(:,:,:,:) = 0._wp   ;   rab_n(:,:,:,:) = 0._wp      ! set one for all to 0 at level jpk
82#if defined key_agrif
83      uu   (:,:,:  ,Kaa) = 0._wp   ! used in agrif_oce_sponge at initialization
84      vv   (:,:,:  ,Kaa) = 0._wp   ! used in agrif_oce_sponge at initialization   
85#endif
86
87      IF( ln_rstart ) THEN                    ! Restart from a file
88         !                                    ! -------------------
89         CALL rst_read( Kbb, Kmm )            ! Read the restart file
90         IF (ln_iscpl)       CALL iscpl_stp( Kbb, Kmm )   ! extrapolate restart to wet and dry
91         CALL day_init                        ! model calendar (using both namelist and restart infos)
92         !
93      ELSE                                    ! Start from rest
94         !                                    ! ---------------
95         numror = 0                           ! define numror = 0 -> no restart file to read
96         neuler = 0                           ! Set time-step indicator at nit000 (euler forward)
97         CALL day_init                        ! model calendar (using both namelist and restart infos)
98         !                                    ! Initialization of ocean to zero
99         !
100         IF( ln_tsd_init ) THEN               
101            CALL dta_tsd( nit000, ts(:,:,:,:,Kbb) )       ! read 3D T and S data at nit000
102            !
103            ssh(:,:,Kbb)   = 0._wp               ! set the ocean at rest
104            IF( ll_wd ) THEN
105               ssh(:,:,Kbb) =  -ssh_ref  ! Added in 30 here for bathy that adds 30 as Iterative test CEOD
106               !
107               ! Apply minimum wetdepth criterion
108               !
109               DO jj = 1,jpj
110                  DO ji = 1,jpi
111                     IF( ht_0(ji,jj) + ssh(ji,jj,Kbb)  < rn_wdmin1 ) THEN
112                        ssh(ji,jj,Kbb) = tmask(ji,jj,1)*( rn_wdmin1 - (ht_0(ji,jj)) )
113                     ENDIF
114                  END DO
115               END DO
116            ENDIF
117            uu  (:,:,:,Kbb) = 0._wp
118            vv  (:,:,:,Kbb) = 0._wp 
119            !
120         ELSE                                 ! user defined initial T and S
121            CALL usr_def_istate( gdept(:,:,:,Kbb), tmask, ts(:,:,:,:,Kbb), uu(:,:,:,Kbb), vv(:,:,:,Kbb), ssh(:,:,Kbb)  )         
122         ENDIF
123         ts  (:,:,:,:,Kmm) = ts (:,:,:,:,Kbb)       ! set now values from to before ones
124         ssh (:,:,Kmm)     = ssh(:,:,Kbb)   
125         uu   (:,:,:,Kmm)   = uu  (:,:,:,Kbb)
126         vv   (:,:,:,Kmm)   = vv  (:,:,:,Kbb)
127         hdiv(:,:,jpk) = 0._wp               ! bottom divergence set one for 0 to zero at jpk level
128         CALL div_hor( 0, Kbb, Kmm )         ! compute interior hdiv value 
129!!gm                                    hdiv(:,:,:) = 0._wp
130
131!!gm POTENTIAL BUG :
132!!gm  ISSUE :  if ssh(:,:,Kbb) /= 0  then, in non linear free surface, the e3._n, e3._b should be recomputed
133!!             as well as gdept and gdepw....   !!!!!
134!!      ===>>>>   probably a call to domvvl initialisation here....
135
136
137         !
138!!gm to be moved in usrdef of C1D case
139!         IF ( ln_uvd_init .AND. lk_c1d ) THEN ! read 3D U and V data at nit000
140!            ALLOCATE( zuvd(jpi,jpj,jpk,2) )
141!            CALL dta_uvd( nit000, zuvd )
142!            uu(:,:,:,Kbb) = zuvd(:,:,:,1) ;  uu(:,:,:,Kmm) = uu(:,:,:,Kbb)
143!            vv(:,:,:,Kbb) = zuvd(:,:,:,2) ;  vv(:,:,:,Kmm) = vv(:,:,:,Kbb)
144!            DEALLOCATE( zuvd )
145!         ENDIF
146         !
147!!gm This is to be changed !!!!
148!         ! - ML - ssh(:,:,Kmm) could be modified by istate_eel, so that initialization of e3t(:,:,:,Kbb) is done here
149!         IF( .NOT.ln_linssh ) THEN
150!            DO jk = 1, jpk
151!               e3t(:,:,jk,Kbb) = e3t(:,:,jk,Kmm)
152!            END DO
153!         ENDIF
154!!gm
155         !
156      ENDIF 
157      !
158      ! Initialize "now" and "before" barotropic velocities:
159      ! Do it whatever the free surface method, these arrays being eventually used
160      !
161      uu_b(:,:,Kmm) = 0._wp   ;   vv_b(:,:,Kmm) = 0._wp
162      uu_b(:,:,Kbb) = 0._wp   ;   vv_b(:,:,Kbb) = 0._wp
163      !
164!!gm  the use of umsak & vmask is not necessary below as uu(:,:,:,Kmm), vv(:,:,:,Kmm), uu(:,:,:,Kbb), vv(:,:,:,Kbb) are always masked
165      DO jk = 1, jpkm1
166         DO jj = 1, jpj
167            DO ji = 1, jpi
168               uu_b(ji,jj,Kmm) = uu_b(ji,jj,Kmm) + e3u(ji,jj,jk,Kmm) * uu(ji,jj,jk,Kmm) * umask(ji,jj,jk)
169               vv_b(ji,jj,Kmm) = vv_b(ji,jj,Kmm) + e3v(ji,jj,jk,Kmm) * vv(ji,jj,jk,Kmm) * vmask(ji,jj,jk)
170               !
171               uu_b(ji,jj,Kbb) = uu_b(ji,jj,Kbb) + e3u(ji,jj,jk,Kbb) * uu(ji,jj,jk,Kbb) * umask(ji,jj,jk)
172               vv_b(ji,jj,Kbb) = vv_b(ji,jj,Kbb) + e3v(ji,jj,jk,Kbb) * vv(ji,jj,jk,Kbb) * vmask(ji,jj,jk)
173            END DO
174         END DO
175      END DO
176      !
177      uu_b(:,:,Kmm) = uu_b(:,:,Kmm) * r1_hu_n(:,:)
178      vv_b(:,:,Kmm) = vv_b(:,:,Kmm) * r1_hv_n(:,:)
179      !
180      uu_b(:,:,Kbb) = uu_b(:,:,Kbb) * r1_hu_b(:,:)
181      vv_b(:,:,Kbb) = vv_b(:,:,Kbb) * r1_hv_b(:,:)
182      !
183   END SUBROUTINE istate_init
184
185   !!======================================================================
186END MODULE istate
Note: See TracBrowser for help on using the repository browser.