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/trunk/src/OCE/DOM – NEMO

source: NEMO/trunk/src/OCE/DOM/istate.F90 @ 10068

Last change on this file since 10068 was 10068, checked in by nicolasmartin, 6 years ago

First part of modifications to have a common default header : fix typos and SVN keywords properties

  • Property svn:keywords set to Id
File size: 8.0 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 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)
[593]29   USE domvvl          ! varying vertical mesh
[6140]30   USE iscplrst        ! ice sheet coupling
[7646]31   USE wet_dry         ! wetting and drying (needed for wad_istate)
32   USE usrdef_istate   ! User defined initial state
[4990]33   !
34   USE in_out_manager  ! I/O manager
35   USE iom             ! I/O library
[2715]36   USE lib_mpp         ! MPP library
[3680]37   USE restart         ! restart
[2715]38
[3]39   IMPLICIT NONE
40   PRIVATE
41
[508]42   PUBLIC   istate_init   ! routine called by step.F90
[3]43
44   !! * Substitutions
45#  include "vectopt_loop_substitute.h90"
46   !!----------------------------------------------------------------------
[9598]47   !! NEMO/OCE 4.0 , NEMO Consortium (2018)
[888]48   !! $Id$
[10068]49   !! Software governed by the CeCILL license (see ./LICENSE)
[3]50   !!----------------------------------------------------------------------
51CONTAINS
52
53   SUBROUTINE istate_init
54      !!----------------------------------------------------------------------
55      !!                   ***  ROUTINE istate_init  ***
56      !!
[508]57      !! ** Purpose :   Initialization of the dynamics and tracer fields.
[3]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
78      tsa  (:,:,:,:) = 0._wp                                   ! set one for all to 0 at level jpk
79      rab_b(:,:,:,:) = 0._wp   ;   rab_n(:,:,:,:) = 0._wp      ! set one for all to 0 at level jpk
[9453]80#if defined key_agrif
[9570]81      ua   (:,:,:  ) = 0._wp   ! used in agrif_oce_sponge at initialization
82      va   (:,:,:  ) = 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         !                                    ! -------------------
[6140]87         CALL rst_read                        ! Read the restart file
[7646]88         IF (ln_iscpl)       CALL iscpl_stp   ! extrapolate restart to wet and dry
[6140]89         CALL day_init                        ! model calendar (using both namelist and restart infos)
[7646]90         !
91      ELSE                                    ! Start from rest
[3]92         !                                    ! ---------------
[7646]93         numror = 0                           ! define numror = 0 -> no restart file to read
94         neuler = 0                           ! Set time-step indicator at nit000 (euler forward)
95         CALL day_init                        ! model calendar (using both namelist and restart infos)
96         !                                    ! Initialization of ocean to zero
[508]97         !
[7646]98         IF( ln_tsd_init ) THEN               
99            CALL dta_tsd( nit000, tsb )       ! read 3D T and S data at nit000
100            !
[7753]101            sshb(:,:)   = 0._wp               ! set the ocean at rest
102            ub  (:,:,:) = 0._wp
103            vb  (:,:,:) = 0._wp 
[7646]104            !
105         ELSE                                 ! user defined initial T and S
106            CALL usr_def_istate( gdept_b, tmask, tsb, ub, vb, sshb  )         
[3]107         ENDIF
[7753]108         tsn  (:,:,:,:) = tsb (:,:,:,:)       ! set now values from to before ones
109         sshn (:,:)     = sshb(:,:)   
110         un   (:,:,:)   = ub  (:,:,:)
111         vn   (:,:,:)   = vb  (:,:,:)
112         hdivn(:,:,jpk) = 0._wp               ! bottom divergence set one for 0 to zero at jpk level
[7646]113         CALL div_hor( 0 )                    ! compute interior hdivn value 
114!!gm                                    hdivn(:,:,:) = 0._wp
115
116!!gm POTENTIAL BUG :
117!!gm  ISSUE :  if sshb /= 0  then, in non linear free surface, the e3._n, e3._b should be recomputed
118!!             as well as gdept and gdepw....   !!!!!
119!!      ===>>>>   probably a call to domvvl initialisation here....
120
121
[6140]122         !
[7646]123!!gm to be moved in usrdef of C1D case
124!         IF ( ln_uvd_init .AND. lk_c1d ) THEN ! read 3D U and V data at nit000
[9019]125!            ALLOCATE( zuvd(jpi,jpj,jpk,2) )
[7646]126!            CALL dta_uvd( nit000, zuvd )
127!            ub(:,:,:) = zuvd(:,:,:,1) ;  un(:,:,:) = ub(:,:,:)
128!            vb(:,:,:) = zuvd(:,:,:,2) ;  vn(:,:,:) = vb(:,:,:)
[9019]129!            DEALLOCATE( zuvd )
[7646]130!         ENDIF
131         !
[6140]132!!gm This is to be changed !!!!
[7646]133!         ! - ML - sshn could be modified by istate_eel, so that initialization of e3t_b is done here
134!         IF( .NOT.ln_linssh ) THEN
135!            DO jk = 1, jpk
136!               e3t_b(:,:,jk) = e3t_n(:,:,jk)
137!            END DO
138!         ENDIF
[6140]139!!gm
[2148]140         !
[7646]141      ENDIF 
[4354]142      !
143      ! Initialize "now" and "before" barotropic velocities:
[6140]144      ! Do it whatever the free surface method, these arrays being eventually used
[4354]145      !
[7753]146      un_b(:,:) = 0._wp   ;   vn_b(:,:) = 0._wp
147      ub_b(:,:) = 0._wp   ;   vb_b(:,:) = 0._wp
[4354]148      !
[7646]149!!gm  the use of umsak & vmask is not necessary below as un, vn, ub, vb are always masked
[4354]150      DO jk = 1, jpkm1
151         DO jj = 1, jpj
152            DO ji = 1, jpi
[6140]153               un_b(ji,jj) = un_b(ji,jj) + e3u_n(ji,jj,jk) * un(ji,jj,jk) * umask(ji,jj,jk)
154               vn_b(ji,jj) = vn_b(ji,jj) + e3v_n(ji,jj,jk) * vn(ji,jj,jk) * vmask(ji,jj,jk)
[4354]155               !
[6140]156               ub_b(ji,jj) = ub_b(ji,jj) + e3u_b(ji,jj,jk) * ub(ji,jj,jk) * umask(ji,jj,jk)
157               vb_b(ji,jj) = vb_b(ji,jj) + e3v_b(ji,jj,jk) * vb(ji,jj,jk) * vmask(ji,jj,jk)
[4354]158            END DO
159         END DO
160      END DO
161      !
[7753]162      un_b(:,:) = un_b(:,:) * r1_hu_n(:,:)
163      vn_b(:,:) = vn_b(:,:) * r1_hv_n(:,:)
[4354]164      !
[7753]165      ub_b(:,:) = ub_b(:,:) * r1_hu_b(:,:)
166      vb_b(:,:) = vb_b(:,:) * r1_hv_b(:,:)
167      !
[3]168   END SUBROUTINE istate_init
169
[7646]170   !!======================================================================
[3]171END MODULE istate
Note: See TracBrowser for help on using the repository browser.