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