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/2020/dev_r13327_KERNEL-06_2_techene_e3/src/OCE/DOM – NEMO

source: NEMO/branches/2020/dev_r13327_KERNEL-06_2_techene_e3/src/OCE/DOM/istate.F90 @ 13607

Last change on this file since 13607 was 13607, checked in by techene, 21 months ago

#2385 cosmetics and F-point loops changed

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