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