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 ! Print control passive tracers (prt_ctl_init routine) |
---|
23 | USE trcrst |
---|
24 | USE lib_mpp ! distribued memory computing library |
---|
25 | USE trcice ! tracers in sea ice |
---|
26 | USE trcbc ! generalized Boundary Conditions |
---|
27 | USE trcais ! tracers from Antartic Ice Sheet |
---|
28 | |
---|
29 | IMPLICIT NONE |
---|
30 | PRIVATE |
---|
31 | |
---|
32 | PUBLIC trc_init ! called by opa |
---|
33 | |
---|
34 | # include "domzgr_substitute.h90" |
---|
35 | !!---------------------------------------------------------------------- |
---|
36 | !! NEMO/TOP 4.0 , NEMO Consortium (2018) |
---|
37 | !! $Id$ |
---|
38 | !! Software governed by the CeCILL license (see ./LICENSE) |
---|
39 | !!---------------------------------------------------------------------- |
---|
40 | CONTAINS |
---|
41 | |
---|
42 | SUBROUTINE trc_init( Kbb, Kmm, Kaa ) |
---|
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 | INTEGER, INTENT(in) :: Kbb, Kmm, Kaa ! time level indices |
---|
55 | ! |
---|
56 | IF( ln_timing ) CALL timing_start('trc_init') |
---|
57 | ! |
---|
58 | IF(lwp) WRITE(numout,*) |
---|
59 | IF(lwp) WRITE(numout,*) 'trc_init : initial set up of the passive tracers' |
---|
60 | IF(lwp) WRITE(numout,*) '~~~~~~~~' |
---|
61 | ! |
---|
62 | CALL trc_nam ! read passive tracers namelists |
---|
63 | CALL top_alloc() ! allocate TOP arrays |
---|
64 | |
---|
65 | ! |
---|
66 | IF(.NOT.ln_trcdta ) ln_trc_ini(:) = .FALSE. |
---|
67 | ! |
---|
68 | IF(lwp) WRITE(numout,*) |
---|
69 | IF( ln_rsttr .AND. .NOT. l_offline ) CALL trc_rst_cal( nit000, 'READ' ) ! calendar |
---|
70 | IF(lwp) WRITE(numout,*) |
---|
71 | ! |
---|
72 | CALL trc_ini_sms( Kmm ) ! SMS |
---|
73 | CALL trc_ini_trp ! passive tracers transport |
---|
74 | CALL trc_ice_ini ! Tracers in sea ice |
---|
75 | ! |
---|
76 | IF( lwm .AND. sn_cfctl%l_trcstat ) THEN |
---|
77 | CALL ctl_opn( numstr, 'tracer.stat', 'REPLACE', 'FORMATTED', 'SEQUENTIAL', -1, numout, lwp , narea ) |
---|
78 | ENDIF |
---|
79 | ! |
---|
80 | CALL trc_ini_state( Kbb, Kmm, Kaa ) ! passive tracers initialisation : from a restart or from clim |
---|
81 | ! |
---|
82 | CALL trc_ini_inv( Kmm ) ! Inventories |
---|
83 | ! |
---|
84 | IF( ln_timing ) CALL timing_stop('trc_init') |
---|
85 | ! |
---|
86 | END SUBROUTINE trc_init |
---|
87 | |
---|
88 | |
---|
89 | SUBROUTINE trc_ini_inv( Kmm ) |
---|
90 | !!---------------------------------------------------------------------- |
---|
91 | !! *** ROUTINE trc_ini_stat *** |
---|
92 | !! ** Purpose : passive tracers inventories at initialsation phase |
---|
93 | !!---------------------------------------------------------------------- |
---|
94 | INTEGER, INTENT(in) :: Kmm ! time level index |
---|
95 | INTEGER :: jk, jn ! dummy loop indices |
---|
96 | CHARACTER (len=25) :: charout |
---|
97 | REAL(wp), DIMENSION(jpi,jpj,jpk,jptra) :: zzmsk |
---|
98 | CHARACTER (len=25), DIMENSION(jptra) :: clseb |
---|
99 | !!---------------------------------------------------------------------- |
---|
100 | ! |
---|
101 | IF(lwp) WRITE(numout,*) |
---|
102 | IF(lwp) WRITE(numout,*) 'trc_ini_inv : initial passive tracers inventories' |
---|
103 | IF(lwp) WRITE(numout,*) '~~~~~~~~~~~' |
---|
104 | ! |
---|
105 | ! ! masked grid volume |
---|
106 | DO jk = 1, jpk |
---|
107 | cvol(:,:,jk) = e1e2t(:,:) * e3t(:,:,jk,Kmm) * tmask(:,:,jk) |
---|
108 | END DO |
---|
109 | ! ! total volume of the ocean |
---|
110 | areatot = glob_sum( 'trcini', cvol(:,:,:) ) |
---|
111 | ! |
---|
112 | trai(:) = 0._wp ! initial content of all tracers |
---|
113 | DO jn = 1, jptra |
---|
114 | trai(jn) = trai(jn) + glob_sum( 'trcini', tr(:,:,:,jn,Kmm) * cvol(:,:,:) ) |
---|
115 | END DO |
---|
116 | |
---|
117 | IF(lwp) THEN ! control print |
---|
118 | WRITE(numout,*) |
---|
119 | WRITE(numout,*) ' ==>>> Total number of passive tracer jptra = ', jptra |
---|
120 | WRITE(numout,*) ' Total volume of ocean = ', areatot |
---|
121 | WRITE(numout,*) ' Total inital content of all tracers ' |
---|
122 | WRITE(numout,*) |
---|
123 | DO jn = 1, jptra |
---|
124 | WRITE(numout,9000) jn, TRIM( ctrcnm(jn) ), trai(jn) |
---|
125 | ENDDO |
---|
126 | WRITE(numout,*) |
---|
127 | ENDIF |
---|
128 | IF(lwp) WRITE(numout,*) |
---|
129 | IF(sn_cfctl%l_prttrc) THEN ! print mean trends (used for debugging) |
---|
130 | CALL prt_ctl_init( 'top', jptra ) |
---|
131 | WRITE(charout, FMT="('ini ')") |
---|
132 | CALL prt_ctl_info( charout, cdcomp = 'top' ) |
---|
133 | CALL prt_ctl( tab4d_1=tr(:,:,:,:,Kmm), mask1=tmask, clinfo=ctrcnm ) |
---|
134 | DO jn = 1, jptra |
---|
135 | zzmsk(:,:,:,jn) = tmask(:,:,:) |
---|
136 | WRITE(clseb(jn),'(a,i2.2)') 'seb ', jn |
---|
137 | END DO |
---|
138 | CALL prt_ctl( tab4d_1=zzmsk, mask1=tmask, clinfo=clseb ) |
---|
139 | ENDIF |
---|
140 | 9000 FORMAT(' tracer nb : ',i2,' name :',a10,' initial content :',e18.10) |
---|
141 | ! |
---|
142 | END SUBROUTINE trc_ini_inv |
---|
143 | |
---|
144 | |
---|
145 | SUBROUTINE trc_ini_sms( Kmm ) |
---|
146 | !!---------------------------------------------------------------------- |
---|
147 | !! *** ROUTINE trc_ini_sms *** |
---|
148 | !! ** Purpose : SMS initialisation |
---|
149 | !!---------------------------------------------------------------------- |
---|
150 | USE trcini_pisces ! PISCES initialisation |
---|
151 | USE trcini_cfc ! CFC initialisation |
---|
152 | USE trcini_c14 ! C14 initialisation |
---|
153 | USE trcini_age ! age initialisation |
---|
154 | USE trcini_my_trc ! MY_TRC initialisation |
---|
155 | ! |
---|
156 | INTEGER, INTENT(in) :: Kmm ! time level indices |
---|
157 | INTEGER :: jn |
---|
158 | !!---------------------------------------------------------------------- |
---|
159 | ! |
---|
160 | ! Pass sn_tracer fields to specialized arrays |
---|
161 | DO jn = 1, jp_bgc |
---|
162 | ctrcnm (jn) = TRIM( sn_tracer(jn)%clsname ) |
---|
163 | ctrcln (jn) = TRIM( sn_tracer(jn)%cllname ) |
---|
164 | ctrcun (jn) = TRIM( sn_tracer(jn)%clunit ) |
---|
165 | ln_trc_ini(jn) = sn_tracer(jn)%llinit |
---|
166 | ln_trc_sbc(jn) = sn_tracer(jn)%llsbc |
---|
167 | ln_trc_cbc(jn) = sn_tracer(jn)%llcbc |
---|
168 | ln_trc_obc(jn) = sn_tracer(jn)%llobc |
---|
169 | ln_trc_ais(jn) = sn_tracer(jn)%llais |
---|
170 | END DO |
---|
171 | ! |
---|
172 | IF( .NOT.ln_trcbc ) THEN |
---|
173 | DO jn = 1, jp_bgc |
---|
174 | ln_trc_sbc(jn) = .FALSE. |
---|
175 | ln_trc_cbc(jn) = .FALSE. |
---|
176 | ln_trc_obc(jn) = .FALSE. |
---|
177 | END DO |
---|
178 | ENDIF |
---|
179 | |
---|
180 | lltrcbc = ( COUNT(ln_trc_sbc) + COUNT(ln_trc_obc) + COUNT(ln_trc_cbc) ) > 0 |
---|
181 | ! |
---|
182 | IF( ln_pisces ) CALL trc_ini_pisces( Kmm ) ! PISCES model |
---|
183 | IF( ln_my_trc ) CALL trc_ini_my_trc( Kmm ) ! MY_TRC model |
---|
184 | IF( ll_cfc ) CALL trc_ini_cfc ( Kmm ) ! CFC's |
---|
185 | IF( ln_c14 ) CALL trc_ini_c14 ( Kmm ) ! C14 model |
---|
186 | IF( ln_age ) CALL trc_ini_age ( Kmm ) ! AGE |
---|
187 | ! |
---|
188 | IF(lwp) THEN ! control print |
---|
189 | WRITE(numout,*) |
---|
190 | WRITE(numout,*) 'trc_init_sms : Summary for selected passive tracers' |
---|
191 | WRITE(numout,*) '~~~~~~~~~~~~' |
---|
192 | WRITE(numout,*) ' ID NAME INI SBC CBC OBC AIS' |
---|
193 | DO jn = 1, jptra |
---|
194 | WRITE(numout,9001) jn, TRIM(ctrcnm(jn)), ln_trc_ini(jn),ln_trc_sbc(jn),ln_trc_cbc(jn),ln_trc_obc(jn),ln_trc_ais(jn) |
---|
195 | END DO |
---|
196 | ENDIF |
---|
197 | IF( lwp .AND. ln_trcbc .AND. lltrcbc ) THEN |
---|
198 | WRITE(numout,*) |
---|
199 | WRITE(numout,*) ' Applying tracer boundary conditions ' |
---|
200 | ENDIF |
---|
201 | ! |
---|
202 | IF( lwp .AND. ln_trcais ) THEN |
---|
203 | WRITE(numout,*) |
---|
204 | WRITE(numout,*) ' Applying tracer from Antarctic Ice Sheet ' |
---|
205 | ENDIF |
---|
206 | |
---|
207 | 9001 FORMAT(3x,i3,1x,a10,3x,l2,3x,l2,3x,l2,3x,l2,3x,l2) |
---|
208 | ! |
---|
209 | END SUBROUTINE trc_ini_sms |
---|
210 | |
---|
211 | |
---|
212 | SUBROUTINE trc_ini_trp |
---|
213 | !!---------------------------------------------------------------------- |
---|
214 | !! *** ROUTINE trc_ini_trp *** |
---|
215 | !! |
---|
216 | !! ** Purpose : Allocate all the dynamic arrays of the OPA modules |
---|
217 | !!---------------------------------------------------------------------- |
---|
218 | USE trcdmp , ONLY: trc_dmp_ini |
---|
219 | USE trcadv , ONLY: trc_adv_ini |
---|
220 | USE trcldf , ONLY: trc_ldf_ini |
---|
221 | USE trcrad , ONLY: trc_rad_ini |
---|
222 | USE trcsink, ONLY: trc_sink_ini |
---|
223 | ! |
---|
224 | INTEGER :: ierr |
---|
225 | !!---------------------------------------------------------------------- |
---|
226 | ! |
---|
227 | IF( ln_trcdmp ) CALL trc_dmp_ini ! damping |
---|
228 | CALL trc_adv_ini ! advection |
---|
229 | CALL trc_ldf_ini ! lateral diffusion |
---|
230 | ! ! vertical diffusion: always implicit time stepping scheme |
---|
231 | CALL trc_rad_ini ! positivity of passive tracers |
---|
232 | CALL trc_sink_ini ! Vertical sedimentation of particles |
---|
233 | ! |
---|
234 | END SUBROUTINE trc_ini_trp |
---|
235 | |
---|
236 | |
---|
237 | SUBROUTINE trc_ini_state( Kbb, Kmm, Kaa ) |
---|
238 | !!---------------------------------------------------------------------- |
---|
239 | !! *** ROUTINE trc_ini_state *** |
---|
240 | !! ** Purpose : Initialisation of passive tracer concentration |
---|
241 | !!---------------------------------------------------------------------- |
---|
242 | USE zpshde ! partial step: hor. derivative (zps_hde routine) |
---|
243 | USE trcrst ! passive tracers restart |
---|
244 | USE trcdta ! initialisation from files |
---|
245 | ! |
---|
246 | INTEGER, INTENT(in) :: Kbb, Kmm, Kaa ! time level index |
---|
247 | INTEGER :: jn, jl ! dummy loop indices |
---|
248 | !!---------------------------------------------------------------------- |
---|
249 | ! |
---|
250 | IF( ln_trcdta ) CALL trc_dta_ini( jptra ) ! set initial tracers values |
---|
251 | ! |
---|
252 | IF( ln_trcbc .AND. lltrcbc ) THEN |
---|
253 | CALL trc_bc_ini ( jptra, Kmm ) ! set tracers Boundary Conditions |
---|
254 | CALL trc_bc ( nit000, Kmm, tr, Kaa ) ! tracers: surface and lateral Boundary Conditions |
---|
255 | ENDIF |
---|
256 | ! |
---|
257 | IF( ln_trcais ) CALL trc_ais_ini ! set tracers from Antarctic Ice Sheet |
---|
258 | ! |
---|
259 | IF( ln_rsttr ) THEN ! restart from a file |
---|
260 | ! |
---|
261 | CALL trc_rst_read( Kbb, Kmm ) |
---|
262 | ! |
---|
263 | ELSE ! Initialisation of tracer from a file that may also be used for damping |
---|
264 | !!gm BUG ? if damping and restart, what's happening ? |
---|
265 | IF( ln_trcdta .AND. nb_trcdta > 0 ) THEN |
---|
266 | ! update passive tracers arrays with input data read from file |
---|
267 | DO jn = 1, jptra |
---|
268 | IF( ln_trc_ini(jn) ) THEN |
---|
269 | jl = n_trc_index(jn) |
---|
270 | CALL trc_dta( nit000, Kmm, sf_trcdta(jl), rf_trfac(jl), tr(:,:,:,jn,Kmm) ) |
---|
271 | ! |
---|
272 | ! deallocate data structure if data are not used for damping |
---|
273 | IF( .NOT.ln_trcdmp .AND. .NOT.ln_trcdmp_clo ) THEN |
---|
274 | IF(lwp) WRITE(numout,*) 'trc_ini_state: deallocate data arrays as they are only used to initialize the run' |
---|
275 | DEALLOCATE( sf_trcdta(jl)%fnow ) |
---|
276 | IF( sf_trcdta(jl)%ln_tint ) DEALLOCATE( sf_trcdta(jl)%fdta ) |
---|
277 | ! |
---|
278 | ENDIF |
---|
279 | ENDIF |
---|
280 | END DO |
---|
281 | ! |
---|
282 | ENDIF |
---|
283 | ! |
---|
284 | tr(:,:,:,:,Kbb) = tr(:,:,:,:,Kmm) |
---|
285 | ! |
---|
286 | ENDIF |
---|
287 | ! |
---|
288 | tr(:,:,:,:,Kaa) = 0._wp |
---|
289 | ! ! Partial top/bottom cell: GRADh(tr(Kmm)) |
---|
290 | END SUBROUTINE trc_ini_state |
---|
291 | |
---|
292 | |
---|
293 | SUBROUTINE top_alloc |
---|
294 | !!---------------------------------------------------------------------- |
---|
295 | !! *** ROUTINE top_alloc *** |
---|
296 | !! |
---|
297 | !! ** Purpose : Allocate all the dynamic arrays of the OPA modules |
---|
298 | !!---------------------------------------------------------------------- |
---|
299 | USE trc , ONLY: trc_alloc |
---|
300 | USE trdtrc_oce , ONLY: trd_trc_oce_alloc |
---|
301 | #if defined key_trdmxl_trc |
---|
302 | USE trdmxl_trc , ONLY: trd_mxl_trc_alloc |
---|
303 | #endif |
---|
304 | ! |
---|
305 | INTEGER :: ierr ! local integer |
---|
306 | !!---------------------------------------------------------------------- |
---|
307 | ! |
---|
308 | ierr = trc_alloc() |
---|
309 | ierr = ierr + trd_trc_oce_alloc() |
---|
310 | #if defined key_trdmxl_trc |
---|
311 | ierr = ierr + trd_mxl_trc_alloc() |
---|
312 | #endif |
---|
313 | ! |
---|
314 | CALL mpp_sum( 'trcini', ierr ) |
---|
315 | IF( ierr /= 0 ) CALL ctl_stop( 'STOP', 'top_alloc : unable to allocate standard ocean arrays' ) |
---|
316 | ! |
---|
317 | END SUBROUTINE top_alloc |
---|
318 | |
---|
319 | #else |
---|
320 | !!---------------------------------------------------------------------- |
---|
321 | !! Empty module : No passive tracer |
---|
322 | !!---------------------------------------------------------------------- |
---|
323 | CONTAINS |
---|
324 | SUBROUTINE trc_init ! Dummy routine |
---|
325 | END SUBROUTINE trc_init |
---|
326 | #endif |
---|
327 | |
---|
328 | !!====================================================================== |
---|
329 | END MODULE trcini |
---|