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 @ 10922

Last change on this file since 10922 was 10922, checked in by acc, 5 years ago

2019/dev_r10721_KERNEL-02_Storkey_Coward_IMMERSE_first_steps : Convert IOM, LDF, OBS and SBC directories and compatibility changes elsewhere that these changes enforce. Changes pass SETTE and compare with original trunk results. Outstanding issues (currently with work-arounds) in DIU/step_diu.F90 and fld_bdy_interp within SBC/fldread.F90; proper soltions pending

  • Property svn:keywords set to Id
File size: 8.6 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 )
54      !!----------------------------------------------------------------------
55      !!                   ***  ROUTINE istate_init  ***
56      !!
57      !! ** Purpose :   Initialization of the dynamics and tracer fields.
58      !!----------------------------------------------------------------------
59      INTEGER, INTENT(in) ::   Kbb, Kmm   ! ocean time level indices
60      INTEGER ::   ji, jj, jk   ! dummy loop indices
61!!gm see comment further down
62      REAL(wp), ALLOCATABLE, DIMENSION(:,:,:,:) ::   zuvd    ! U & V data workspace
63!!gm end
64      !!----------------------------------------------------------------------
65      !
66      IF(lwp) WRITE(numout,*)
67      IF(lwp) WRITE(numout,*) 'istate_init : Initialization of the dynamics and tracers'
68      IF(lwp) WRITE(numout,*) '~~~~~~~~~~~'
69
70!!gm  Why not include in the first call of dta_tsd ? 
71!!gm  probably associated with the use of internal damping...
72                     CALL dta_tsd_init        ! Initialisation of T & S input data
73!!gm to be moved in usrdef of C1D case
74!      IF( lk_c1d )   CALL dta_uvd_init        ! Initialization of U & V input data
75!!gm
76
77      rhd  (:,:,:  ) = 0._wp   ;   rhop (:,:,:  ) = 0._wp      ! set one for all to 0 at level jpk
78      rn2b (:,:,:  ) = 0._wp   ;   rn2  (:,:,:  ) = 0._wp      ! set one for all to 0 at levels 1 and jpk
79      tsa  (:,:,:,:) = 0._wp                                   ! set one for all to 0 at level jpk
80      rab_b(:,:,:,:) = 0._wp   ;   rab_n(:,:,:,:) = 0._wp      ! set one for all to 0 at level jpk
81#if defined key_agrif
82      ua   (:,:,:  ) = 0._wp   ! used in agrif_oce_sponge at initialization
83      va   (:,:,:  ) = 0._wp   ! used in agrif_oce_sponge at initialization   
84#endif
85
86      IF( ln_rstart ) THEN                    ! Restart from a file
87         !                                    ! -------------------
88         CALL rst_read( Kbb, Kmm )            ! Read the restart file
89         IF (ln_iscpl)       CALL iscpl_stp   ! extrapolate restart to wet and dry
90         CALL day_init                        ! model calendar (using both namelist and restart infos)
91         !
92      ELSE                                    ! 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         !
99         IF( ln_tsd_init ) THEN               
100            CALL dta_tsd( nit000, tsb )       ! read 3D T and S data at nit000
101            !
102            sshb(:,:)   = 0._wp               ! set the ocean at rest
103            IF( ll_wd ) THEN
104               sshb(:,:) =  -ssh_ref  ! Added in 30 here for bathy that adds 30 as Iterative test CEOD
105               !
106               ! Apply minimum wetdepth criterion
107               !
108               DO jj = 1,jpj
109                  DO ji = 1,jpi
110                     IF( ht_0(ji,jj) + sshb(ji,jj)  < rn_wdmin1 ) THEN
111                        sshb(ji,jj) = tmask(ji,jj,1)*( rn_wdmin1 - (ht_0(ji,jj)) )
112                     ENDIF
113                  END DO
114               END DO
115            ENDIF
116            ub  (:,:,:) = 0._wp
117            vb  (:,:,:) = 0._wp 
118            !
119         ELSE                                 ! user defined initial T and S
120            CALL usr_def_istate( gdept_b, tmask, tsb, ub, vb, sshb  )         
121         ENDIF
122         tsn  (:,:,:,:) = tsb (:,:,:,:)       ! set now values from to before ones
123         sshn (:,:)     = sshb(:,:)   
124         un   (:,:,:)   = ub  (:,:,:)
125         vn   (:,:,:)   = vb  (:,:,:)
126         hdivn(:,:,jpk) = 0._wp               ! bottom divergence set one for 0 to zero at jpk level
127         CALL div_hor( 0, Kmm )               ! compute interior hdivn value 
128!!gm                                    hdivn(:,:,:) = 0._wp
129
130!!gm POTENTIAL BUG :
131!!gm  ISSUE :  if sshb /= 0  then, in non linear free surface, the e3._n, e3._b should be recomputed
132!!             as well as gdept and gdepw....   !!!!!
133!!      ===>>>>   probably a call to domvvl initialisation here....
134
135
136         !
137!!gm to be moved in usrdef of C1D case
138!         IF ( ln_uvd_init .AND. lk_c1d ) THEN ! read 3D U and V data at nit000
139!            ALLOCATE( zuvd(jpi,jpj,jpk,2) )
140!            CALL dta_uvd( nit000, zuvd )
141!            ub(:,:,:) = zuvd(:,:,:,1) ;  un(:,:,:) = ub(:,:,:)
142!            vb(:,:,:) = zuvd(:,:,:,2) ;  vn(:,:,:) = vb(:,:,:)
143!            DEALLOCATE( zuvd )
144!         ENDIF
145         !
146!!gm This is to be changed !!!!
147!         ! - ML - sshn could be modified by istate_eel, so that initialization of e3t_b is done here
148!         IF( .NOT.ln_linssh ) THEN
149!            DO jk = 1, jpk
150!               e3t_b(:,:,jk) = e3t_n(:,:,jk)
151!            END DO
152!         ENDIF
153!!gm
154         !
155      ENDIF 
156      !
157      ! Initialize "now" and "before" barotropic velocities:
158      ! Do it whatever the free surface method, these arrays being eventually used
159      !
160      un_b(:,:) = 0._wp   ;   vn_b(:,:) = 0._wp
161      ub_b(:,:) = 0._wp   ;   vb_b(:,:) = 0._wp
162      !
163!!gm  the use of umsak & vmask is not necessary below as un, vn, ub, vb are always masked
164      DO jk = 1, jpkm1
165         DO jj = 1, jpj
166            DO ji = 1, jpi
167               un_b(ji,jj) = un_b(ji,jj) + e3u_n(ji,jj,jk) * un(ji,jj,jk) * umask(ji,jj,jk)
168               vn_b(ji,jj) = vn_b(ji,jj) + e3v_n(ji,jj,jk) * vn(ji,jj,jk) * vmask(ji,jj,jk)
169               !
170               ub_b(ji,jj) = ub_b(ji,jj) + e3u_b(ji,jj,jk) * ub(ji,jj,jk) * umask(ji,jj,jk)
171               vb_b(ji,jj) = vb_b(ji,jj) + e3v_b(ji,jj,jk) * vb(ji,jj,jk) * vmask(ji,jj,jk)
172            END DO
173         END DO
174      END DO
175      !
176      un_b(:,:) = un_b(:,:) * r1_hu_n(:,:)
177      vn_b(:,:) = vn_b(:,:) * r1_hv_n(:,:)
178      !
179      ub_b(:,:) = ub_b(:,:) * r1_hu_b(:,:)
180      vb_b(:,:) = vb_b(:,:) * r1_hv_b(:,:)
181      !
182   END SUBROUTINE istate_init
183
184   !!======================================================================
185END MODULE istate
Note: See TracBrowser for help on using the repository browser.