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 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 | USE wrk_nemo ! Memory allocation |
---|
39 | USE timing ! Timing |
---|
40 | |
---|
41 | IMPLICIT NONE |
---|
42 | PRIVATE |
---|
43 | |
---|
44 | PUBLIC istate_init ! routine called by step.F90 |
---|
45 | |
---|
46 | !! * Substitutions |
---|
47 | # include "vectopt_loop_substitute.h90" |
---|
48 | !!---------------------------------------------------------------------- |
---|
49 | !! NEMO/OPA 3.7 , NEMO Consortium (2014) |
---|
50 | !! $Id$ |
---|
51 | !! Software governed by the CeCILL licence (NEMOGCM/NEMO_CeCILL.txt) |
---|
52 | !!---------------------------------------------------------------------- |
---|
53 | CONTAINS |
---|
54 | |
---|
55 | SUBROUTINE istate_init |
---|
56 | !!---------------------------------------------------------------------- |
---|
57 | !! *** ROUTINE istate_init *** |
---|
58 | !! |
---|
59 | !! ** Purpose : Initialization of the dynamics and tracer fields. |
---|
60 | !!---------------------------------------------------------------------- |
---|
61 | INTEGER :: ji, jj, jk ! dummy loop indices |
---|
62 | REAL(wp), POINTER, DIMENSION(:,:,:,:) :: zuvd ! U & V data workspace |
---|
63 | !!---------------------------------------------------------------------- |
---|
64 | ! |
---|
65 | IF( nn_timing == 1 ) CALL timing_start('istate_init') |
---|
66 | ! |
---|
67 | IF(lwp) WRITE(numout,*) |
---|
68 | IF(lwp) WRITE(numout,*) 'istate_init : Initialization of the dynamics and tracers' |
---|
69 | IF(lwp) WRITE(numout,*) '~~~~~~~~~~~' |
---|
70 | |
---|
71 | !!gm Why not include in the first call of dta_tsd ? |
---|
72 | !!gm probably associated with the use of internal damping... |
---|
73 | CALL dta_tsd_init ! Initialisation of T & S input data |
---|
74 | !!gm to be moved in usrdef of C1D case |
---|
75 | ! IF( lk_c1d ) CALL dta_uvd_init ! Initialization of U & V input data |
---|
76 | !!gm |
---|
77 | |
---|
78 | rhd (:,:,: ) = 0._wp ; rhop (:,:,: ) = 0._wp ! set one for all to 0 at level jpk |
---|
79 | rn2b (:,:,: ) = 0._wp ; rn2 (:,:,: ) = 0._wp ! set one for all to 0 at levels 1 and jpk |
---|
80 | tsa (:,:,:,:) = 0._wp ! set one for all to 0 at level jpk |
---|
81 | rab_b(:,:,:,:) = 0._wp ; rab_n(:,:,:,:) = 0._wp ! set one for all to 0 at level jpk |
---|
82 | |
---|
83 | IF( ln_rstart ) THEN ! Restart from a file |
---|
84 | ! ! ------------------- |
---|
85 | CALL rst_read ! Read the restart file |
---|
86 | IF (ln_iscpl) CALL iscpl_stp ! extrapolate restart to wet and dry |
---|
87 | CALL day_init ! model calendar (using both namelist and restart infos) |
---|
88 | ! |
---|
89 | ELSE ! Start from rest |
---|
90 | ! ! --------------- |
---|
91 | numror = 0 ! define numror = 0 -> no restart file to read |
---|
92 | neuler = 0 ! Set time-step indicator at nit000 (euler forward) |
---|
93 | CALL day_init ! model calendar (using both namelist and restart infos) |
---|
94 | ! ! Initialization of ocean to zero |
---|
95 | ! |
---|
96 | IF( ln_tsd_init ) THEN |
---|
97 | CALL dta_tsd( nit000, tsb ) ! read 3D T and S data at nit000 |
---|
98 | ! |
---|
99 | sshb(:,:) = 0._wp ! set the ocean at rest |
---|
100 | ub (:,:,:) = 0._wp |
---|
101 | vb (:,:,:) = 0._wp |
---|
102 | ! |
---|
103 | ELSE ! user defined initial T and S |
---|
104 | CALL usr_def_istate( gdept_b, tmask, tsb, ub, vb, sshb ) |
---|
105 | ENDIF |
---|
106 | tsn (:,:,:,:) = tsb (:,:,:,:) ! set now values from to before ones |
---|
107 | sshn (:,:) = sshb(:,:) |
---|
108 | un (:,:,:) = ub (:,:,:) |
---|
109 | vn (:,:,:) = vb (:,:,:) |
---|
110 | hdivn(:,:,jpk) = 0._wp ! bottom divergence set one for 0 to zero at jpk level |
---|
111 | CALL div_hor( 0 ) ! compute interior hdivn value |
---|
112 | !!gm hdivn(:,:,:) = 0._wp |
---|
113 | |
---|
114 | !!gm POTENTIAL BUG : |
---|
115 | !!gm ISSUE : if sshb /= 0 then, in non linear free surface, the e3._n, e3._b should be recomputed |
---|
116 | !! as well as gdept and gdepw.... !!!!! |
---|
117 | !! ===>>>> probably a call to domvvl initialisation here.... |
---|
118 | |
---|
119 | |
---|
120 | ! |
---|
121 | !!gm to be moved in usrdef of C1D case |
---|
122 | ! IF ( ln_uvd_init .AND. lk_c1d ) THEN ! read 3D U and V data at nit000 |
---|
123 | ! CALL wrk_alloc( jpi,jpj,jpk,2, zuvd ) |
---|
124 | ! CALL dta_uvd( nit000, zuvd ) |
---|
125 | ! ub(:,:,:) = zuvd(:,:,:,1) ; un(:,:,:) = ub(:,:,:) |
---|
126 | ! vb(:,:,:) = zuvd(:,:,:,2) ; vn(:,:,:) = vb(:,:,:) |
---|
127 | ! CALL wrk_dealloc( jpi,jpj,jpk,2, zuvd ) |
---|
128 | ! ENDIF |
---|
129 | ! |
---|
130 | !!gm This is to be changed !!!! |
---|
131 | ! ! - ML - sshn could be modified by istate_eel, so that initialization of e3t_b is done here |
---|
132 | ! IF( .NOT.ln_linssh ) THEN |
---|
133 | ! DO jk = 1, jpk |
---|
134 | ! e3t_b(:,:,jk) = e3t_n(:,:,jk) |
---|
135 | ! END DO |
---|
136 | ! ENDIF |
---|
137 | !!gm |
---|
138 | ! |
---|
139 | ENDIF |
---|
140 | ! |
---|
141 | ! Initialize "now" and "before" barotropic velocities: |
---|
142 | ! Do it whatever the free surface method, these arrays being eventually used |
---|
143 | ! |
---|
144 | un_b(:,:) = 0._wp ; vn_b(:,:) = 0._wp |
---|
145 | ub_b(:,:) = 0._wp ; vb_b(:,:) = 0._wp |
---|
146 | ! |
---|
147 | !!gm the use of umsak & vmask is not necessary below as un, vn, ub, vb are always masked |
---|
148 | DO jk = 1, jpkm1 |
---|
149 | DO jj = 1, jpj |
---|
150 | DO ji = 1, jpi |
---|
151 | un_b(ji,jj) = un_b(ji,jj) + e3u_n(ji,jj,jk) * un(ji,jj,jk) * umask(ji,jj,jk) |
---|
152 | vn_b(ji,jj) = vn_b(ji,jj) + e3v_n(ji,jj,jk) * vn(ji,jj,jk) * vmask(ji,jj,jk) |
---|
153 | ! |
---|
154 | ub_b(ji,jj) = ub_b(ji,jj) + e3u_b(ji,jj,jk) * ub(ji,jj,jk) * umask(ji,jj,jk) |
---|
155 | vb_b(ji,jj) = vb_b(ji,jj) + e3v_b(ji,jj,jk) * vb(ji,jj,jk) * vmask(ji,jj,jk) |
---|
156 | END DO |
---|
157 | END DO |
---|
158 | END DO |
---|
159 | ! |
---|
160 | un_b(:,:) = un_b(:,:) * r1_hu_n(:,:) |
---|
161 | vn_b(:,:) = vn_b(:,:) * r1_hv_n(:,:) |
---|
162 | ! |
---|
163 | ub_b(:,:) = ub_b(:,:) * r1_hu_b(:,:) |
---|
164 | vb_b(:,:) = vb_b(:,:) * r1_hv_b(:,:) |
---|
165 | ! |
---|
166 | IF( nn_timing == 1 ) CALL timing_stop('istate_init') |
---|
167 | ! |
---|
168 | END SUBROUTINE istate_init |
---|
169 | |
---|
170 | !!====================================================================== |
---|
171 | END MODULE istate |
---|