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

source: NEMO/branches/2021/ticket2680_C1D_PAPA/src/OCE/DOM/istate.F90 @ 15006

Last change on this file since 15006 was 15006, checked in by gsamson, 3 years ago

continue C1D_PAPA cleaning (#2680): remove specific c1D step and dyn_cor routines

  • Property svn:keywords set to Id
File size: 8.1 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
[15006]31   USE c1d
[4990]32   !
33   USE in_out_manager  ! I/O manager
34   USE iom             ! I/O library
[2715]35   USE lib_mpp         ! MPP library
[3680]36   USE restart         ! restart
[14086]37
[13216]38#if defined key_agrif
[14086]39   USE agrif_oce       ! initial state interpolation
[13216]40   USE agrif_oce_interp
41#endif   
[2715]42
[3]43   IMPLICIT NONE
44   PRIVATE
45
[14053]46   PUBLIC   istate_init   ! routine called by nemogcm.F90
[3]47
48   !! * Substitutions
[12377]49#  include "do_loop_substitute.h90"
[13237]50#  include "domzgr_substitute.h90"
[3]51   !!----------------------------------------------------------------------
[9598]52   !! NEMO/OCE 4.0 , NEMO Consortium (2018)
[888]53   !! $Id$
[10068]54   !! Software governed by the CeCILL license (see ./LICENSE)
[3]55   !!----------------------------------------------------------------------
56CONTAINS
57
[12377]58   SUBROUTINE istate_init( Kbb, Kmm, Kaa )
[3]59      !!----------------------------------------------------------------------
60      !!                   ***  ROUTINE istate_init  ***
61      !!
[508]62      !! ** Purpose :   Initialization of the dynamics and tracer fields.
[14053]63      !!
64      !! ** Method  :   
[3]65      !!----------------------------------------------------------------------
[12377]66      INTEGER, INTENT( in )  ::  Kbb, Kmm, Kaa   ! ocean time level indices
67      !
[7753]68      INTEGER ::   ji, jj, jk   ! dummy loop indices
[14053]69      REAL(wp), DIMENSION(jpi,jpj,jpk) ::   zgdept     ! 3D table for qco substitute
[9019]70!!gm see comment further down
71      REAL(wp), ALLOCATABLE, DIMENSION(:,:,:,:) ::   zuvd    ! U & V data workspace
72!!gm end
[3294]73      !!----------------------------------------------------------------------
74      !
[5836]75      IF(lwp) WRITE(numout,*)
[7646]76      IF(lwp) WRITE(numout,*) 'istate_init : Initialization of the dynamics and tracers'
77      IF(lwp) WRITE(numout,*) '~~~~~~~~~~~'
[3]78
[13216]79       CALL dta_tsd_init        ! Initialisation of T & S input data
[14053]80
[7646]81!      IF( lk_c1d )   CALL dta_uvd_init        ! Initialization of U & V input data
[3]82
[14053]83      rhd  (:,:,:      ) = 0._wp   ;   rhop (:,:,:  ) = 0._wp      ! set one for all to 0 at level jpk
84      rn2b (:,:,:      ) = 0._wp   ;   rn2  (:,:,:  ) = 0._wp      ! set one for all to 0 at levels 1 and jpk
85      ts   (:,:,:,:,Kaa) = 0._wp                                   ! set one for all to 0 at level jpk
86      rab_b(:,:,:,:    ) = 0._wp   ;   rab_n(:,:,:,:) = 0._wp      ! set one for all to 0 at level jpk
[9453]87#if defined key_agrif
[12377]88      uu   (:,:,:  ,Kaa) = 0._wp   ! used in agrif_oce_sponge at initialization
89      vv   (:,:,:  ,Kaa) = 0._wp   ! used in agrif_oce_sponge at initialization   
[9453]90#endif
[7753]91
[13216]92#if defined key_agrif
[14139]93      IF ( .NOT.Agrif_root() .AND. ln_init_chfrpar ) THEN
[13216]94         numror = 0                           ! define numror = 0 -> no restart file to read
95         ln_1st_euler = .true.                ! Set time-step indicator at nit000 (euler forward)
96         CALL day_init 
[14086]97         CALL agrif_istate_oce( Kbb, Kmm, Kaa )   ! Interp from parent
[13216]98         !
[14053]99         ts (:,:,:,:,Kmm) = ts (:,:,:,:,Kbb)
100         uu (:,:,:  ,Kmm) = uu (:,:,:  ,Kbb)
101         vv (:,:,:  ,Kmm) = vv (:,:,:  ,Kbb)
[13216]102      ELSE
103#endif
[14086]104         IF( ln_rstart ) THEN                    ! Restart from a file
105            !                                    ! -------------------
106            CALL rst_read( Kbb, Kmm )            ! Read the restart file
107            CALL day_init                        ! model calendar (using both namelist and restart infos)
[7646]108            !
[14086]109         ELSE                                    ! Start from rest
110            !                                    ! ---------------
111            numror = 0                           ! define numror = 0 -> no restart file to read
112            l_1st_euler = .true.                 ! Set time-step indicator at nit000 (euler forward)
113            CALL day_init                        ! model calendar (using both namelist and restart infos)
114            !                                    ! Initialization of ocean to zero
[14139]115            !
[14086]116            IF( ln_tsd_init ) THEN               
117               CALL dta_tsd( nit000, ts(:,:,:,:,Kbb) )       ! read 3D T and S data at nit000
118               !
[14139]119               uu  (:,:,:,Kbb) = 0._wp               ! set the ocean at rest
[14086]120               vv  (:,:,:,Kbb) = 0._wp 
121               !
122            ELSE                                 ! user defined initial T and S
123               DO jk = 1, jpk
124                  zgdept(:,:,jk) = gdept(:,:,jk,Kbb)
125               END DO
126               CALL usr_def_istate( zgdept, tmask, ts(:,:,:,:,Kbb), uu(:,:,:,Kbb), vv(:,:,:,Kbb) )         
127            ENDIF
128            ts  (:,:,:,:,Kmm) = ts (:,:,:,:,Kbb)       ! set now values from to before ones
[14139]129            uu    (:,:,:,Kmm) = uu   (:,:,:,Kbb)
130            vv    (:,:,:,Kmm) = vv   (:,:,:,Kbb)
[7646]131
[6140]132         !
[14053]133!!gm ==>>>  to be moved in usrdef_istate of C1D case
134         IF ( ln_uvd_init .AND. lk_c1d ) THEN ! read 3D U and V data at nit000
135            ALLOCATE( zuvd(jpi,jpj,jpk,2) )
136            CALL dta_uvd( nit000, Kbb, zuvd )
137            uu(:,:,:,Kbb) = zuvd(:,:,:,1)  ;  uu(:,:,:,Kmm) = uu(:,:,:,Kbb)
138            vv(:,:,:,Kbb) = zuvd(:,:,:,2)  ;  vv(:,:,:,Kmm) = vv(:,:,:,Kbb)
139            DEALLOCATE( zuvd )
140         ENDIF
[7646]141         !
[2148]142         !
[14086]143         ENDIF 
[13216]144#if defined key_agrif
145      ENDIF
146#endif
[4354]147      !
148      ! Initialize "now" and "before" barotropic velocities:
[6140]149      ! Do it whatever the free surface method, these arrays being eventually used
[4354]150      !
[12377]151      uu_b(:,:,Kmm) = 0._wp   ;   vv_b(:,:,Kmm) = 0._wp
152      uu_b(:,:,Kbb) = 0._wp   ;   vv_b(:,:,Kbb) = 0._wp
[4354]153      !
[12377]154!!gm  the use of umsak & vmask is not necessary below as uu(:,:,:,Kmm), vv(:,:,:,Kmm), uu(:,:,:,Kbb), vv(:,:,:,Kbb) are always masked
[14834]155      DO_3D( nn_hls, nn_hls, nn_hls, nn_hls, 1, jpkm1 )
[12377]156         uu_b(ji,jj,Kmm) = uu_b(ji,jj,Kmm) + e3u(ji,jj,jk,Kmm) * uu(ji,jj,jk,Kmm) * umask(ji,jj,jk)
157         vv_b(ji,jj,Kmm) = vv_b(ji,jj,Kmm) + e3v(ji,jj,jk,Kmm) * vv(ji,jj,jk,Kmm) * vmask(ji,jj,jk)
158         !
159         uu_b(ji,jj,Kbb) = uu_b(ji,jj,Kbb) + e3u(ji,jj,jk,Kbb) * uu(ji,jj,jk,Kbb) * umask(ji,jj,jk)
160         vv_b(ji,jj,Kbb) = vv_b(ji,jj,Kbb) + e3v(ji,jj,jk,Kbb) * vv(ji,jj,jk,Kbb) * vmask(ji,jj,jk)
161      END_3D
[4354]162      !
[12377]163      uu_b(:,:,Kmm) = uu_b(:,:,Kmm) * r1_hu(:,:,Kmm)
164      vv_b(:,:,Kmm) = vv_b(:,:,Kmm) * r1_hv(:,:,Kmm)
[4354]165      !
[12377]166      uu_b(:,:,Kbb) = uu_b(:,:,Kbb) * r1_hu(:,:,Kbb)
167      vv_b(:,:,Kbb) = vv_b(:,:,Kbb) * r1_hv(:,:,Kbb)
[7753]168      !
[3]169   END SUBROUTINE istate_init
170
[7646]171   !!======================================================================
[3]172END MODULE istate
Note: See TracBrowser for help on using the repository browser.