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 | !! - ! 2014-06 (A. Yool, J. Palmieri) adding MEDUSA-2 |
---|
11 | !!---------------------------------------------------------------------- |
---|
12 | #if defined key_top |
---|
13 | !!---------------------------------------------------------------------- |
---|
14 | !! 'key_top' TOP models |
---|
15 | !!---------------------------------------------------------------------- |
---|
16 | !! trc_init : Initialization for passive tracer |
---|
17 | !! top_alloc : allocate the TOP arrays |
---|
18 | !!---------------------------------------------------------------------- |
---|
19 | USE oce_trc ! shared variables between ocean and passive tracers |
---|
20 | USE trc ! passive tracers common variables |
---|
21 | USE trcrst ! passive tracers restart |
---|
22 | USE trcnam ! Namelist read |
---|
23 | USE trcini_cfc ! CFC initialisation |
---|
24 | USE trcini_pisces ! PISCES initialisation |
---|
25 | USE trcini_c14b ! C14 bomb initialisation |
---|
26 | USE trcini_age ! AGE initialisation |
---|
27 | USE trcini_my_trc ! MY_TRC initialisation |
---|
28 | USE trcini_idtra ! idealize tracer initialisation |
---|
29 | USE trcini_medusa ! MEDUSA initialisation |
---|
30 | USE par_medusa ! MEDUSA parameters (needed for elemental cycles) |
---|
31 | USE trcdta ! initialisation from files |
---|
32 | USE daymod ! calendar manager |
---|
33 | USE prtctl_trc ! Print control passive tracers (prt_ctl_trc_init routine) |
---|
34 | USE trcsub ! variables to substep passive tracers |
---|
35 | USE lib_mpp ! distribued memory computing library |
---|
36 | USE sbc_oce |
---|
37 | USE trcice ! tracers in sea ice |
---|
38 | USE sms_medusa ! MEDUSA initialisation |
---|
39 | IMPLICIT NONE |
---|
40 | PRIVATE |
---|
41 | |
---|
42 | PUBLIC trc_init ! called by opa |
---|
43 | |
---|
44 | !! * Substitutions |
---|
45 | # include "domzgr_substitute.h90" |
---|
46 | !!---------------------------------------------------------------------- |
---|
47 | !! NEMO/TOP 4.0 , NEMO Consortium (2011) |
---|
48 | !! $Id$ |
---|
49 | !! Software governed by the CeCILL licence (NEMOGCM/NEMO_CeCILL.txt) |
---|
50 | !!---------------------------------------------------------------------- |
---|
51 | CONTAINS |
---|
52 | |
---|
53 | SUBROUTINE trc_init |
---|
54 | !!--------------------------------------------------------------------- |
---|
55 | !! *** ROUTINE trc_init *** |
---|
56 | !! |
---|
57 | !! ** Purpose : Initialization of the passive tracer fields |
---|
58 | !! |
---|
59 | !! ** Method : - read namelist |
---|
60 | !! - control the consistancy |
---|
61 | !! - compute specific initialisations |
---|
62 | !! - set initial tracer fields (either read restart |
---|
63 | !! or read data or analytical formulation |
---|
64 | !!--------------------------------------------------------------------- |
---|
65 | INTEGER :: ji, jj, jk, jn, jl ! dummy loop indices |
---|
66 | # if defined key_medusa && defined key_roam |
---|
67 | !! AXY (23/11/2017) |
---|
68 | REAL(wp) :: zsum3d, zsum2d |
---|
69 | REAL(wp) :: zq1, zq2, loc_vol, loc_area |
---|
70 | REAL(wp), DIMENSION(6) :: loc_cycletot3, loc_cycletot2 |
---|
71 | REAL(wp), DIMENSION(jpi,jpj,jpk) :: ztot3d |
---|
72 | REAL(wp), DIMENSION(jpi,jpj) :: ztot2d, carea |
---|
73 | # endif |
---|
74 | CHARACTER (len=25) :: charout |
---|
75 | !!--------------------------------------------------------------------- |
---|
76 | ! |
---|
77 | IF( nn_timing == 1 ) CALL timing_start('trc_init') |
---|
78 | ! |
---|
79 | IF(lwp) WRITE(numout,*) |
---|
80 | IF(lwp) WRITE(numout,*) 'trc_init : initial set up of the passive tracers' |
---|
81 | IF(lwp) WRITE(numout,*) '~~~~~~~' |
---|
82 | |
---|
83 | CALL top_alloc() ! allocate TOP arrays |
---|
84 | |
---|
85 | l_trcdm2dc = ln_dm2dc .OR. ( ln_cpl .AND. ncpl_qsr_freq /= 1 ) |
---|
86 | l_trcdm2dc = l_trcdm2dc .AND. .NOT. lk_offline |
---|
87 | IF( l_trcdm2dc .AND. lwp ) & |
---|
88 | & CALL ctl_warn(' Coupling with passive tracers and used of diurnal cycle. & |
---|
89 | & Computation of a daily mean shortwave for some biogeochemical models) ') |
---|
90 | |
---|
91 | IF( nn_cla == 1 ) & |
---|
92 | & CALL ctl_stop( ' Cross Land Advection not yet implemented with passive tracer ; nn_cla must be 0' ) |
---|
93 | |
---|
94 | CALL trc_nam ! read passive tracers namelists |
---|
95 | ! |
---|
96 | IF(lwp) WRITE(numout,*) |
---|
97 | ! |
---|
98 | IF( ln_rsttr .AND. .NOT. lk_offline ) CALL trc_rst_cal( nit000, 'READ' ) ! calendar |
---|
99 | ! |
---|
100 | IF(lwp) WRITE(numout,*) |
---|
101 | ! masked grid volume |
---|
102 | ! ! masked grid volume |
---|
103 | DO jk = 1, jpk |
---|
104 | cvol(:,:,jk) = e1e2t(:,:) * fse3t(:,:,jk) * tmask(:,:,jk) |
---|
105 | END DO |
---|
106 | IF( lk_degrad ) cvol(:,:,:) = cvol(:,:,:) * facvol(:,:,:) ! degrad option: reduction by facvol |
---|
107 | ! ! total volume of the ocean |
---|
108 | areatot = glob_sum( cvol(:,:,:) ) |
---|
109 | carea(:,:) = e1e2t(:,:) * tmask(:,:,1) |
---|
110 | |
---|
111 | IF( lk_pisces ) CALL trc_ini_pisces ! PISCES bio-model |
---|
112 | IF( lk_cfc ) CALL trc_ini_cfc ! CFC tracers |
---|
113 | IF( lk_c14b ) CALL trc_ini_c14b ! C14 bomb tracer |
---|
114 | IF( lk_age ) CALL trc_ini_age ! AGE tracer |
---|
115 | IF( lk_my_trc ) CALL trc_ini_my_trc ! MY_TRC tracers |
---|
116 | IF( lk_idtra ) CALL trc_ini_idtra ! Idealize tracers |
---|
117 | IF( lk_medusa ) CALL trc_ini_medusa ! MEDUSA tracers |
---|
118 | |
---|
119 | CALL trc_ice_ini ! Tracers in sea ice |
---|
120 | |
---|
121 | IF( ln_ctl ) THEN |
---|
122 | ! |
---|
123 | IF (narea == 1) THEN |
---|
124 | ! The tracer.stat file only contains global tracer sum values, if |
---|
125 | ! it contains anything at all. Hence it only needs to be opened |
---|
126 | ! and written to on the master PE, not on all PEs. |
---|
127 | CALL ctl_opn( numstr, 'tracer.stat', 'REPLACE','FORMATTED', & |
---|
128 | 'SEQUENTIAL', -1, numout, lwp , narea ) |
---|
129 | ENDIF |
---|
130 | ! |
---|
131 | ENDIF |
---|
132 | |
---|
133 | IF( ln_trcdta ) THEN |
---|
134 | CALL trc_dta_init(jptra) |
---|
135 | ENDIF |
---|
136 | |
---|
137 | IF( ln_rsttr ) THEN |
---|
138 | ! |
---|
139 | CALL trc_rst_read ! restart from a file |
---|
140 | ! |
---|
141 | ELSE |
---|
142 | ! |
---|
143 | IF( ln_trcdta .AND. nb_trcdta > 0 ) THEN ! Initialisation of tracer from a file that may also be used for damping |
---|
144 | ! |
---|
145 | DO jn = 1, jptra |
---|
146 | IF( ln_trc_ini(jn) ) THEN ! update passive tracers arrays with input data read from file |
---|
147 | jl = n_trc_index(jn) |
---|
148 | CALL trc_dta( nit000, sf_trcdta(jl), rf_trfac(jl) ) ! read tracer data at nit000 |
---|
149 | trn(:,:,:,jn) = sf_trcdta(jl)%fnow(:,:,:) |
---|
150 | IF( .NOT.ln_trcdmp .AND. .NOT.ln_trcdmp_clo ) THEN !== deallocate data structure ==! |
---|
151 | ! (data used only for initialisation) |
---|
152 | IF(lwp) WRITE(numout,*) 'trc_dta: deallocate data arrays as they are only used to initialize the run' |
---|
153 | DEALLOCATE( sf_trcdta(jl)%fnow ) ! arrays in the structure |
---|
154 | IF( sf_trcdta(jl)%ln_tint ) DEALLOCATE( sf_trcdta(jl)%fdta ) |
---|
155 | ! |
---|
156 | ENDIF |
---|
157 | ENDIF |
---|
158 | ENDDO |
---|
159 | ! |
---|
160 | ENDIF |
---|
161 | ! |
---|
162 | trb(:,:,:,:) = trn(:,:,:,:) |
---|
163 | ! |
---|
164 | ENDIF |
---|
165 | |
---|
166 | tra(:,:,:,:) = 0._wp |
---|
167 | ! |
---|
168 | IF( nn_dttrc /= 1 ) CALL trc_sub_ini ! Initialize variables for substepping passive tracers |
---|
169 | ! |
---|
170 | |
---|
171 | trai(:) = 0._wp ! initial content of all tracers |
---|
172 | DO jn = 1, jptra |
---|
173 | trai(jn) = trai(jn) + glob_sum( trn(:,:,:,jn) * cvol(:,:,:) ) |
---|
174 | END DO |
---|
175 | |
---|
176 | IF(lwp) THEN ! control print |
---|
177 | WRITE(numout,*) |
---|
178 | WRITE(numout,*) |
---|
179 | WRITE(numout,*) ' *** Total number of passive tracer jptra = ', jptra |
---|
180 | WRITE(numout,*) ' *** Total volume of ocean = ', areatot |
---|
181 | WRITE(numout,*) ' *** Total inital content of all tracers ' |
---|
182 | WRITE(numout,*) |
---|
183 | # if defined key_debug_medusa |
---|
184 | CALL flush(numout) |
---|
185 | # endif |
---|
186 | ! |
---|
187 | # if defined key_debug_medusa |
---|
188 | WRITE(numout,*) ' litle check : ', ctrcnm(1) |
---|
189 | CALL flush(numout) |
---|
190 | # endif |
---|
191 | DO jn = 1, jptra |
---|
192 | WRITE(numout,9000) jn, TRIM( ctrcnm(jn) ), trai(jn) |
---|
193 | ENDDO |
---|
194 | WRITE(numout,*) |
---|
195 | ENDIF |
---|
196 | IF(lwp) WRITE(numout,*) |
---|
197 | IF(ln_ctl) THEN ! print mean trends (used for debugging) |
---|
198 | CALL prt_ctl_trc_init |
---|
199 | WRITE(charout, FMT="('ini ')") |
---|
200 | CALL prt_ctl_trc_info( charout ) |
---|
201 | CALL prt_ctl_trc( tab4d=trn, mask=tmask, clinfo=ctrcnm ) |
---|
202 | ENDIF |
---|
203 | |
---|
204 | # if defined key_medusa && defined key_roam |
---|
205 | ! AXY (17/11/2017): calculate initial totals of elemental cycles |
---|
206 | ! |
---|
207 | ! This is done in a very hard-wired way here; in future, this could be |
---|
208 | ! replaced with loops and using a 2D array; one dimension would cover |
---|
209 | ! the tracers, the other would be for the elements; each tracer would |
---|
210 | ! have a factor for each element to say how much of that element was |
---|
211 | ! in that tracer; for example, PHN would be 1.0 for N, xrfn for Fe and |
---|
212 | ! xthetapn for C, with the other elements 0.0; the array entry for PHN |
---|
213 | ! would then be (1. 0. xrfn xthetapn 0. 0.) for (N, Si, Fe, C, A, O2); |
---|
214 | ! saving this for the next iteration |
---|
215 | ! |
---|
216 | cycletot(:) = 0._wp |
---|
217 | ! report elemental totals at initialisation as we go along |
---|
218 | IF ( lwp ) WRITE(numout,*) |
---|
219 | IF ( lwp ) WRITE(numout,*) ' Elemental cycle totals: ' |
---|
220 | ! nitrogen |
---|
221 | ztot3d(:,:,:) = trn(:,:,:,jpphn) + trn(:,:,:,jpphd) + trn(:,:,:,jpzmi) + & |
---|
222 | trn(:,:,:,jpzme) + trn(:,:,:,jpdet) + trn(:,:,:,jpdin) |
---|
223 | ztot2d(:,:) = zn_sed_n(:,:) |
---|
224 | zsum3d = glob_sum( ztot3d(:,:,:) * cvol(:,:,:) ) |
---|
225 | zsum2d = glob_sum( ztot2d(:,:) * carea(:,:) ) |
---|
226 | cycletot(1) = zsum3d + zsum2d |
---|
227 | IF ( lwp ) WRITE(numout,9010) 'nitrogen', zsum3d, zsum2d, cycletot(1) |
---|
228 | ! silicon |
---|
229 | ztot3d(:,:,:) = trn(:,:,:,jppds) + trn(:,:,:,jpsil) |
---|
230 | ztot2d(:,:) = zn_sed_si(:,:) |
---|
231 | zsum3d = glob_sum( ztot3d(:,:,:) * cvol(:,:,:) ) |
---|
232 | zsum2d = glob_sum( ztot2d(:,:) * carea(:,:) ) |
---|
233 | cycletot(2) = zsum3d + zsum2d |
---|
234 | IF ( lwp ) WRITE(numout,9010) 'silicon', zsum3d, zsum2d, cycletot(2) |
---|
235 | ! iron |
---|
236 | ztot3d(:,:,:) = ((trn(:,:,:,jpphn) + trn(:,:,:,jpphd) + trn(:,:,:,jpzmi) + & |
---|
237 | trn(:,:,:,jpzme) + trn(:,:,:,jpdet)) * xrfn) + trn(:,:,:,jpfer) |
---|
238 | ztot2d(:,:) = zn_sed_fe(:,:) |
---|
239 | zsum3d = glob_sum( ztot3d(:,:,:) * cvol(:,:,:) ) |
---|
240 | zsum2d = glob_sum( ztot2d(:,:) * carea(:,:) ) |
---|
241 | cycletot(3) = zsum3d + zsum2d |
---|
242 | IF ( lwp ) WRITE(numout,9010) 'iron', zsum3d, zsum2d, cycletot(3) |
---|
243 | ! carbon (uses fixed C:N ratios on plankton tracers) |
---|
244 | ztot3d(:,:,:) = (trn(:,:,:,jpphn) * xthetapn) + (trn(:,:,:,jpphd) * xthetapd) + & |
---|
245 | (trn(:,:,:,jpzmi) * xthetazmi) + (trn(:,:,:,jpzme) * xthetazme) + & |
---|
246 | trn(:,:,:,jpdtc) + trn(:,:,:,jpdic) |
---|
247 | ztot2d(:,:) = zn_sed_c(:,:) + zn_sed_ca(:,:) |
---|
248 | zsum3d = glob_sum( ztot3d(:,:,:) * cvol(:,:,:) ) |
---|
249 | zsum2d = glob_sum( ztot2d(:,:) * carea(:,:) ) |
---|
250 | cycletot(4) = zsum3d + zsum2d |
---|
251 | IF ( lwp ) WRITE(numout,9010) 'carbon', zsum3d, zsum2d, cycletot(4) |
---|
252 | ! alkalinity (note benthic correction) |
---|
253 | ztot3d(:,:,:) = trn(:,:,:,jpalk) |
---|
254 | ztot2d(:,:) = zn_sed_ca(:,:) * 2._wp |
---|
255 | zsum3d = glob_sum( ztot3d(:,:,:) * cvol(:,:,:) ) |
---|
256 | zsum2d = glob_sum( ztot2d(:,:) * carea(:,:) ) |
---|
257 | cycletot(5) = zsum3d + zsum2d |
---|
258 | IF ( lwp ) WRITE(numout,9010) 'alkalinity', zsum3d, zsum2d, cycletot(5) |
---|
259 | ! oxygen (note no benthic) |
---|
260 | ztot3d(:,:,:) = trn(:,:,:,jpoxy) |
---|
261 | ztot2d(:,:) = 0._wp |
---|
262 | zsum3d = glob_sum( ztot3d(:,:,:) * cvol(:,:,:) ) |
---|
263 | zsum2d = glob_sum( ztot2d(:,:) * carea(:,:) ) |
---|
264 | cycletot(6) = zsum3d + zsum2d |
---|
265 | IF ( lwp ) WRITE(numout,9010) 'oxygen', zsum3d, zsum2d, cycletot(6) |
---|
266 | ! Check |
---|
267 | zsum3d = glob_sum( cvol(:,:,:) ) |
---|
268 | zsum2d = glob_sum( carea(:,:) ) |
---|
269 | IF ( lwp ) THEN |
---|
270 | WRITE(numout,*) |
---|
271 | WRITE(numout,*) ' check : cvol : ', zsum3d |
---|
272 | WRITE(numout,*) ' check : carea : ', zsum2d |
---|
273 | WRITE(numout,*) |
---|
274 | ENDIF |
---|
275 | ! |
---|
276 | # endif |
---|
277 | |
---|
278 | IF(lwp) THEN |
---|
279 | WRITE(numout,*) |
---|
280 | WRITE(numout,*) 'trc_init : passive tracer set up completed' |
---|
281 | WRITE(numout,*) '~~~~~~~' |
---|
282 | ENDIF |
---|
283 | # if defined key_debug_medusa |
---|
284 | CALL trc_rst_stat |
---|
285 | CALL flush(numout) |
---|
286 | # endif |
---|
287 | |
---|
288 | 9000 FORMAT(' tracer nb : ',i2,' name :',a10,' initial content :',e18.10) |
---|
289 | 9010 FORMAT(' element:',a10, & |
---|
290 | ' 3d sum:',e18.10,' 2d sum:',e18.10, & |
---|
291 | ' total:',e18.10) |
---|
292 | ! |
---|
293 | IF( nn_timing == 1 ) CALL timing_stop('trc_init') |
---|
294 | ! |
---|
295 | END SUBROUTINE trc_init |
---|
296 | |
---|
297 | |
---|
298 | SUBROUTINE top_alloc |
---|
299 | !!---------------------------------------------------------------------- |
---|
300 | !! *** ROUTINE top_alloc *** |
---|
301 | !! |
---|
302 | !! ** Purpose : Allocate all the dynamic arrays of the OPA modules |
---|
303 | !!---------------------------------------------------------------------- |
---|
304 | USE trcadv , ONLY: trc_adv_alloc ! TOP-related alloc routines... |
---|
305 | USE trc , ONLY: trc_alloc |
---|
306 | USE trcnxt , ONLY: trc_nxt_alloc |
---|
307 | USE trczdf , ONLY: trc_zdf_alloc |
---|
308 | USE trdtrc_oce , ONLY: trd_trc_oce_alloc |
---|
309 | #if defined key_trdmxl_trc |
---|
310 | USE trdmxl_trc , ONLY: trd_mxl_trc_alloc |
---|
311 | #endif |
---|
312 | # if defined key_medusa |
---|
313 | USE bio_medusa_mod, ONLY: bio_medusa_alloc |
---|
314 | # endif |
---|
315 | |
---|
316 | ! |
---|
317 | INTEGER :: ierr |
---|
318 | !!---------------------------------------------------------------------- |
---|
319 | ! |
---|
320 | ierr = trc_adv_alloc() ! Start of TOP-related alloc routines... |
---|
321 | ierr = ierr + trc_alloc () |
---|
322 | ierr = ierr + trc_nxt_alloc() |
---|
323 | ierr = ierr + trc_zdf_alloc() |
---|
324 | ierr = ierr + trd_trc_oce_alloc() |
---|
325 | #if defined key_trdmxl_trc |
---|
326 | ierr = ierr + trd_mxl_trc_alloc() |
---|
327 | #endif |
---|
328 | #if defined key_medusa |
---|
329 | ierr = ierr + bio_medusa_alloc() |
---|
330 | #endif |
---|
331 | ! |
---|
332 | IF( lk_mpp ) CALL mpp_sum( ierr ) |
---|
333 | IF( ierr /= 0 ) CALL ctl_stop( 'STOP', 'top_alloc : unable to allocate standard ocean arrays' ) |
---|
334 | ! |
---|
335 | END SUBROUTINE top_alloc |
---|
336 | |
---|
337 | #else |
---|
338 | !!---------------------------------------------------------------------- |
---|
339 | !! Empty module : No passive tracer |
---|
340 | !!---------------------------------------------------------------------- |
---|
341 | CONTAINS |
---|
342 | SUBROUTINE trc_init ! Dummy routine |
---|
343 | END SUBROUTINE trc_init |
---|
344 | #endif |
---|
345 | |
---|
346 | !!====================================================================== |
---|
347 | END MODULE trcini |
---|