1 | MODULE trcini |
---|
2 | !!====================================================================== |
---|
3 | !! *** MODULE trcini *** |
---|
4 | !! TOP : Manage the passive tracer initialization |
---|
5 | !!====================================================================== |
---|
6 | !! History : - ! 1991-03 (O. Marti) original code |
---|
7 | !! 1.0 ! 2005-03 (O. Aumont, A. El Moussaoui) F90 |
---|
8 | !! 2.0 ! 2005-10 (C. Ethe, G. Madec) revised architecture |
---|
9 | !! 4.0 ! 2011-01 (A. R. Porter, STFC Daresbury) dynamical allocation |
---|
10 | !!---------------------------------------------------------------------- |
---|
11 | #if defined key_top |
---|
12 | !!---------------------------------------------------------------------- |
---|
13 | !! 'key_top' TOP models |
---|
14 | !!---------------------------------------------------------------------- |
---|
15 | !! trc_init : Initialization for passive tracer |
---|
16 | !! top_alloc : allocate the TOP arrays |
---|
17 | !!---------------------------------------------------------------------- |
---|
18 | USE oce_trc ! shared variables between ocean and passive tracers |
---|
19 | USE trc ! passive tracers common variables |
---|
20 | USE trcnam ! Namelist read |
---|
21 | USE daymod ! calendar manager |
---|
22 | USE prtctl_trc ! Print control passive tracers (prt_ctl_trc_init routine) |
---|
23 | USE trcsub ! variables to substep passive tracers |
---|
24 | USE trcrst |
---|
25 | USE lib_mpp ! distribued memory computing library |
---|
26 | USE sbc_oce |
---|
27 | USE trcice ! tracers in sea ice |
---|
28 | USE trcbc, only : trc_bc_init ! generalized Boundary Conditions |
---|
29 | |
---|
30 | IMPLICIT NONE |
---|
31 | PRIVATE |
---|
32 | |
---|
33 | PUBLIC trc_init ! called by opa |
---|
34 | |
---|
35 | !!---------------------------------------------------------------------- |
---|
36 | !! NEMO/TOP 4.0 , NEMO Consortium (2011) |
---|
37 | !! $Id$ |
---|
38 | !! Software governed by the CeCILL licence (NEMOGCM/NEMO_CeCILL.txt) |
---|
39 | !!---------------------------------------------------------------------- |
---|
40 | CONTAINS |
---|
41 | |
---|
42 | SUBROUTINE trc_init |
---|
43 | !!--------------------------------------------------------------------- |
---|
44 | !! *** ROUTINE trc_init *** |
---|
45 | !! |
---|
46 | !! ** Purpose : Initialization of the passive tracer fields |
---|
47 | !! |
---|
48 | !! ** Method : - read namelist |
---|
49 | !! - control the consistancy |
---|
50 | !! - compute specific initialisations |
---|
51 | !! - set initial tracer fields (either read restart |
---|
52 | !! or read data or analytical formulation |
---|
53 | !!--------------------------------------------------------------------- |
---|
54 | ! |
---|
55 | IF( nn_timing == 1 ) CALL timing_start('trc_init') |
---|
56 | ! |
---|
57 | IF(lwp) WRITE(numout,*) |
---|
58 | IF(lwp) WRITE(numout,*) 'trc_init : initial set up of the passive tracers' |
---|
59 | IF(lwp) WRITE(numout,*) '~~~~~~~' |
---|
60 | |
---|
61 | IF( .NOT.lk_offline ) CALL trc_nam_run ! Parameters of the run |
---|
62 | ! |
---|
63 | CALL top_alloc() ! allocate TOP arrays |
---|
64 | ! |
---|
65 | CALL trc_ini_ctl ! control |
---|
66 | CALL trc_nam ! read passive tracers namelists |
---|
67 | ! |
---|
68 | ! |
---|
69 | IF(lwp) WRITE(numout,*) |
---|
70 | IF( ln_rsttr .AND. .NOT. lk_offline ) CALL trc_rst_cal( nit000, 'READ' ) ! calendar |
---|
71 | IF(lwp) WRITE(numout,*) |
---|
72 | ! |
---|
73 | CALL trc_ini_sms ! SMS |
---|
74 | CALL trc_ini_trp ! passive tracers transport |
---|
75 | CALL trc_ice_ini ! Tracers in sea ice |
---|
76 | ! |
---|
77 | IF(lwp) CALL ctl_opn( numstr, 'tracer.stat', 'REPLACE', 'FORMATTED', 'SEQUENTIAL', -1, numout, lwp , narea ) |
---|
78 | ! |
---|
79 | CALL trc_ini_state ! passive tracers initialisation : from a restart or from clim |
---|
80 | IF( nn_dttrc /= 1 ) & |
---|
81 | CALL trc_sub_ini ! Initialize variables for substepping passive tracers |
---|
82 | CALL trc_ini_inv ! Inventories |
---|
83 | ! |
---|
84 | IF( nn_timing == 1 ) CALL timing_stop('trc_init') |
---|
85 | ! |
---|
86 | END SUBROUTINE trc_init |
---|
87 | |
---|
88 | |
---|
89 | SUBROUTINE trc_ini_ctl |
---|
90 | !!---------------------------------------------------------------------- |
---|
91 | !! *** ROUTINE trc_ini_ctl *** |
---|
92 | !! ** Purpose : Control + ocean volume |
---|
93 | !!---------------------------------------------------------------------- |
---|
94 | INTEGER :: jk ! dummy loop indices |
---|
95 | ! |
---|
96 | ! Define logical parameter ton control dirunal cycle in TOP |
---|
97 | l_trcdm2dc = ln_dm2dc .OR. ( ln_cpl .AND. ncpl_qsr_freq /= 1 ) |
---|
98 | l_trcdm2dc = l_trcdm2dc .AND. .NOT. lk_offline |
---|
99 | IF( l_trcdm2dc .AND. lwp ) CALL ctl_warn( 'Coupling with passive tracers and used of diurnal cycle.', & |
---|
100 | & 'Computation of a daily mean shortwave for some biogeochemical models ' ) |
---|
101 | ! |
---|
102 | END SUBROUTINE trc_ini_ctl |
---|
103 | |
---|
104 | |
---|
105 | SUBROUTINE trc_ini_inv |
---|
106 | !!---------------------------------------------------------------------- |
---|
107 | !! *** ROUTINE trc_ini_stat *** |
---|
108 | !! ** Purpose : passive tracers inventories at initialsation phase |
---|
109 | !!---------------------------------------------------------------------- |
---|
110 | INTEGER :: jk, jn ! dummy loop indices |
---|
111 | CHARACTER (len=25) :: charout |
---|
112 | !!---------------------------------------------------------------------- |
---|
113 | ! ! masked grid volume |
---|
114 | DO jk = 1, jpk |
---|
115 | cvol(:,:,jk) = e1e2t(:,:) * e3t_n(:,:,jk) * tmask(:,:,jk) |
---|
116 | END DO |
---|
117 | ! ! total volume of the ocean |
---|
118 | areatot = glob_sum( cvol(:,:,:) ) |
---|
119 | ! |
---|
120 | trai(:) = 0._wp ! initial content of all tracers |
---|
121 | DO jn = 1, jptra |
---|
122 | trai(jn) = trai(jn) + glob_sum( trn(:,:,:,jn) * cvol(:,:,:) ) |
---|
123 | END DO |
---|
124 | |
---|
125 | IF(lwp) THEN ! control print |
---|
126 | WRITE(numout,*) |
---|
127 | WRITE(numout,*) |
---|
128 | WRITE(numout,*) ' *** Total number of passive tracer jptra = ', jptra |
---|
129 | WRITE(numout,*) ' *** Total volume of ocean = ', areatot |
---|
130 | WRITE(numout,*) ' *** Total inital content of all tracers ' |
---|
131 | WRITE(numout,*) |
---|
132 | DO jn = 1, jptra |
---|
133 | WRITE(numout,9000) jn, TRIM( ctrcnm(jn) ), trai(jn) |
---|
134 | ENDDO |
---|
135 | WRITE(numout,*) |
---|
136 | ENDIF |
---|
137 | IF(lwp) WRITE(numout,*) |
---|
138 | IF(ln_ctl) THEN ! print mean trends (used for debugging) |
---|
139 | CALL prt_ctl_trc_init |
---|
140 | WRITE(charout, FMT="('ini ')") |
---|
141 | CALL prt_ctl_trc_info( charout ) |
---|
142 | CALL prt_ctl_trc( tab4d=trn, mask=tmask, clinfo=ctrcnm ) |
---|
143 | ENDIF |
---|
144 | 9000 FORMAT(' tracer nb : ',i2,' name :',a10,' initial content :',e18.10) |
---|
145 | ! |
---|
146 | END SUBROUTINE trc_ini_inv |
---|
147 | |
---|
148 | |
---|
149 | SUBROUTINE trc_ini_sms |
---|
150 | !!---------------------------------------------------------------------- |
---|
151 | !! *** ROUTINE trc_ini_sms *** |
---|
152 | !! ** Purpose : SMS initialisation |
---|
153 | !!---------------------------------------------------------------------- |
---|
154 | USE par_trc |
---|
155 | USE trcini_pisces ! PISCES initialisation |
---|
156 | USE trcini_cfc ! CFC initialisation |
---|
157 | USE trcini_c14 ! C14 initialisation |
---|
158 | USE trcini_age ! age initialisation |
---|
159 | USE trcini_my_trc ! MY_TRC initialisation |
---|
160 | !!---------------------------------------------------------------------- |
---|
161 | jp_lc = 0 |
---|
162 | IF( lk_pisces ) THEN ! PISCES bio-model |
---|
163 | CALL trc_ini_pisces |
---|
164 | jp_lc = jp_pisces |
---|
165 | ELSE |
---|
166 | jp_pisces = 0 |
---|
167 | jp_pcs0 = 0 |
---|
168 | jp_pcs1 = 0 |
---|
169 | ENDIF |
---|
170 | IF( lk_my_trc ) THEN ! MY_TRC |
---|
171 | CALL trc_ini_my_trc |
---|
172 | jp_lc = jp_lc + jp_my_trc |
---|
173 | ELSE |
---|
174 | jp_my_trc = 0 |
---|
175 | jp_myt0 = 0 |
---|
176 | jp_myt1 = 0 |
---|
177 | ENDIF |
---|
178 | IF( ll_cfc ) THEN ! CFC |
---|
179 | CALL trc_ini_cfc |
---|
180 | jp_lc = jp_lc + jp_cfc |
---|
181 | ELSE |
---|
182 | jp_cfc = 0 |
---|
183 | jp_cfc0 = 0 |
---|
184 | jp_cfc1 = 0 |
---|
185 | ENDIF |
---|
186 | IF( ln_c14 ) THEN ! C14 |
---|
187 | CALL trc_ini_c14 |
---|
188 | jp_lc = jp_lc + jp_c14 |
---|
189 | ELSE |
---|
190 | jp_c14 = 0 |
---|
191 | jp_c140 = 0 |
---|
192 | ENDIF |
---|
193 | IF( ln_age ) THEN ! AGE |
---|
194 | CALL trc_ini_age |
---|
195 | jp_lc = jp_lc + jp_age |
---|
196 | ELSE |
---|
197 | jp_age = 0 |
---|
198 | jp_age0 = 0 |
---|
199 | ENDIF |
---|
200 | ! |
---|
201 | IF( jp_lc /= jptra ) THEN |
---|
202 | IF( lwp ) WRITE(numout,*) ' The total number of tracers in namelist_top jptra = ', jptra |
---|
203 | IF( lwp ) WRITE(numout,*) ' The total number of tracers to be used by the model is jp_lc = ', jp_lc |
---|
204 | CALL ctl_stop( " Change the value of total number of tracers in namelist " ) |
---|
205 | ENDIF |
---|
206 | ! |
---|
207 | END SUBROUTINE trc_ini_sms |
---|
208 | |
---|
209 | SUBROUTINE trc_ini_trp |
---|
210 | !!---------------------------------------------------------------------- |
---|
211 | !! *** ROUTINE trc_ini_trp *** |
---|
212 | !! |
---|
213 | !! ** Purpose : Allocate all the dynamic arrays of the OPA modules |
---|
214 | !!---------------------------------------------------------------------- |
---|
215 | USE trcdmp , ONLY: trc_dmp_ini |
---|
216 | USE trcadv , ONLY: trc_adv_ini |
---|
217 | USE trcldf , ONLY: trc_ldf_ini |
---|
218 | USE trczdf , ONLY: trc_zdf_ini |
---|
219 | USE trcrad , ONLY: trc_rad_ini |
---|
220 | ! |
---|
221 | INTEGER :: ierr |
---|
222 | !!---------------------------------------------------------------------- |
---|
223 | ! |
---|
224 | IF( ln_trcdmp ) CALL trc_dmp_ini ! damping |
---|
225 | CALL trc_adv_ini ! advection |
---|
226 | CALL trc_ldf_ini ! lateral diffusion |
---|
227 | CALL trc_zdf_ini ! vertical diffusion |
---|
228 | CALL trc_rad_ini ! positivity of passive tracers |
---|
229 | ! |
---|
230 | END SUBROUTINE trc_ini_trp |
---|
231 | |
---|
232 | |
---|
233 | SUBROUTINE trc_ini_state |
---|
234 | !!---------------------------------------------------------------------- |
---|
235 | !! *** ROUTINE trc_ini_state *** |
---|
236 | !! ** Purpose : Initialisation of passive tracer concentration |
---|
237 | !!---------------------------------------------------------------------- |
---|
238 | USE zpshde ! partial step: hor. derivative (zps_hde routine) |
---|
239 | USE trcrst ! passive tracers restart |
---|
240 | USE trcdta ! initialisation from files |
---|
241 | ! |
---|
242 | INTEGER :: jn, jl ! dummy loop indices |
---|
243 | !!---------------------------------------------------------------------- |
---|
244 | ! |
---|
245 | ! Initialisation of tracers Initial Conditions |
---|
246 | IF( ln_trcdta ) CALL trc_dta_init(jptra) |
---|
247 | |
---|
248 | ! Initialisation of tracers Boundary Conditions |
---|
249 | IF( lk_my_trc ) CALL trc_bc_init(jptra) |
---|
250 | |
---|
251 | IF( ln_rsttr ) THEN |
---|
252 | ! |
---|
253 | CALL trc_rst_read ! restart from a file |
---|
254 | ! |
---|
255 | ELSE |
---|
256 | ! |
---|
257 | IF( ln_trcdta .AND. nb_trcdta > 0 ) THEN ! Initialisation of tracer from a file that may also be used for damping |
---|
258 | ! |
---|
259 | DO jn = 1, jptra |
---|
260 | IF( ln_trc_ini(jn) ) THEN ! update passive tracers arrays with input data read from file |
---|
261 | jl = n_trc_index(jn) |
---|
262 | CALL trc_dta( nit000, sf_trcdta(jl), rf_trfac(jl) ) ! read tracer data at nit000 |
---|
263 | trn(:,:,:,jn) = sf_trcdta(jl)%fnow(:,:,:) |
---|
264 | ! |
---|
265 | IF( .NOT.ln_trcdmp .AND. .NOT.ln_trcdmp_clo ) THEN !== deallocate data structure ==! |
---|
266 | ! (data used only for initialisation) |
---|
267 | IF(lwp) WRITE(numout,*) 'trc_dta: deallocate data arrays as they are only used to initialize the run' |
---|
268 | DEALLOCATE( sf_trcdta(jl)%fnow ) ! arrays in the structure |
---|
269 | IF( sf_trcdta(jl)%ln_tint ) DEALLOCATE( sf_trcdta(jl)%fdta ) |
---|
270 | ! |
---|
271 | ENDIF |
---|
272 | ENDIF |
---|
273 | ENDDO |
---|
274 | ! |
---|
275 | ENDIF |
---|
276 | ! |
---|
277 | trb(:,:,:,:) = trn(:,:,:,:) |
---|
278 | ! |
---|
279 | ENDIF |
---|
280 | |
---|
281 | tra(:,:,:,:) = 0._wp |
---|
282 | ! ! Partial top/bottom cell: GRADh(trn) |
---|
283 | END SUBROUTINE trc_ini_state |
---|
284 | |
---|
285 | SUBROUTINE top_alloc |
---|
286 | !!---------------------------------------------------------------------- |
---|
287 | !! *** ROUTINE top_alloc *** |
---|
288 | !! |
---|
289 | !! ** Purpose : Allocate all the dynamic arrays of the OPA modules |
---|
290 | !!---------------------------------------------------------------------- |
---|
291 | USE trc , ONLY: trc_alloc |
---|
292 | USE trdtrc_oce , ONLY: trd_trc_oce_alloc |
---|
293 | #if defined key_trdmxl_trc |
---|
294 | USE trdmxl_trc , ONLY: trd_mxl_trc_alloc |
---|
295 | #endif |
---|
296 | ! |
---|
297 | INTEGER :: ierr |
---|
298 | !!---------------------------------------------------------------------- |
---|
299 | ! |
---|
300 | ierr = trc_alloc() |
---|
301 | ierr = ierr + trd_trc_oce_alloc() |
---|
302 | #if defined key_trdmxl_trc |
---|
303 | ierr = ierr + trd_mxl_trc_alloc() |
---|
304 | #endif |
---|
305 | ! |
---|
306 | IF( lk_mpp ) CALL mpp_sum( ierr ) |
---|
307 | IF( ierr /= 0 ) CALL ctl_stop( 'STOP', 'top_alloc : unable to allocate standard ocean arrays' ) |
---|
308 | ! |
---|
309 | END SUBROUTINE top_alloc |
---|
310 | |
---|
311 | #else |
---|
312 | !!---------------------------------------------------------------------- |
---|
313 | !! Empty module : No passive tracer |
---|
314 | !!---------------------------------------------------------------------- |
---|
315 | CONTAINS |
---|
316 | SUBROUTINE trc_init ! Dummy routine |
---|
317 | END SUBROUTINE trc_init |
---|
318 | #endif |
---|
319 | |
---|
320 | !!====================================================================== |
---|
321 | END MODULE trcini |
---|