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_r12953_ENHANCE-10_acc_fix_traqsr/src/OCE/DOM – NEMO

source: NEMO/branches/2020/dev_r12953_ENHANCE-10_acc_fix_traqsr/src/OCE/DOM/istate.F90 @ 13121

Last change on this file since 13121 was 13121, checked in by acc, 4 years ago

2020/dev_r12953_ENHANCE-10_acc_fix_traqsr. Merge in trunk changes from 12953 to current HEAD (13115). Fully SETTE tested

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