-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtracer.html
357 lines (320 loc) · 17.4 KB
/
tracer.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
<!DOCTYPE html>
<html>
<head>
<title>Brian Blaylock, UofU</title>
<link rel="stylesheet" href="./css/brian_style.css" />
<script src="./js/site/siteopen.js"></script>
</head>
<body>
<a name="TOP"></a>
<script src="./js/site/sitemenu.js"></script>
<div id="content">
<h1 align="center">Tracer Plumes in WRF</h1>
<!-- Tabs -->
<ul class="nav nav-tabs">
<li class="active"><a data-toggle="tab" href="#tab1">Introduction</a></li>
<li><a data-toggle="tab" href="#tab2">namelist.input</a></li>
<li><a data-toggle="tab" href="#tab3">Registry.EM</a></li>
<li><a data-toggle="tab" href="#tab4">module_initialize_real.F</a></li>
<li><a data-toggle="tab" href="#tab5">solve_em.F</a></li>
<li><a data-toggle="tab" href="#tab6">Increase Plume Output</a></li>
<li><a data-toggle="tab" href="#tab7">Example</a></li>
</ul>
<div class="tab-content">
<div id="tab1" class="tab-pane fade in active">
<h3>Introduction to Tracers in WRF</h3>
<img ALIGN=right height="300px" class="style1" src="https://home.chpc.utah.edu/~u0553130/Brian_Blaylock/images/plume_ex2.gif">
<p>Passive tracers have no influence on the model. Instead, they
are influenced by the model. Tracers are added to the model
and WRF blow them around. It's like initiating a puff of smoke
at a location at some time and letting the winds blow the smoke around.
<p>WRF 3.7+ includes a basic framework for creating tracers,
but hopefully you'll find this commentary helpful.
<p>In order to successfully add a tracer to your WRF simulation
you must make edits to the following:
<ol style="padding-left:60px">
<li>WRFV3/test/em_real/namelist.input
<li>WRFV3/Registry/Registry.EM
<li>WRFV3/dyn_em/module_initialize_real.F
<li>WRFV3/dyn_em/solve_em.F
</ol>
<p>Note: When you make changes to (2,3,4) you need to re-compile
the WRF code. When you change (2,4) you need to re-run real.exe.
If you only make changes to (4) then you can re-run wrf.exe after
you re-compile.
<p>It's my suggestion to get the plume initialization working first
by making edits to (1,2,3), then get the continuous plume to working
by making edits to (4).
<div class='alert alert-info'>Note: I'm currently dealing with WRF not writing the restart
files because my tracer variables are larger than
supported by NetCDF requirements. I don't think the tracers
have anything to do with that. The NetCDF file is too large,
so set the namelist.input option io_form_restart = 102 which
will write a restart file for every processor. Just remember
to do the restart WRF with the same number of processors.
</div>
</div>
<div id="tab2" class="tab-pane fade">
<h3>namelist.input</h3>
<p><b style="color:green">namelist.input</b> contains all
the WRF user options.
<p>Here's a copy of my complete <a href='https://github.com/blaylockbk/Ute-WRF-User-Group/blob/master/Blaylock/add_tracer_plumes/namelist.input.bkb.tracer'>namelist.input</a> file.
<p>In the <b>&dynamics</b> section, add <b>tracer_opt</b>.
This is the flag that turns the tracer option on.
<p>The below example shows tracer_opt set to "2" for domain one
and two.
<div class="well well-sm">
<p>...
<p>&dynamics
<p>tracer_opt = 2, 2
<p>/
<p>...
</div>
</div>
<div id="tab3" class="tab-pane fade">
<h3>Registry.EM</h3>
<p><b style="color:green">Registry/Registry.EM</b>
defines output variables in WRF.
<p>Here's a copy of my complete
<a href="https://github.com/blaylockbk/Ute-WRF-User-Group/blob/master/Blaylock/add_tracer_plumes/Registry.EM.bkb.tracer">Registry.EM</a> file.
<p>Below are the the changes I made to Registry.EM...
(Note: don't remove the tr17_* lines. I can't get WRF to
compile when I remove those. But adding to the list is fine.)
<textarea disabled>
#
# Tracer Scalars: If you want full resolved and non-resolved dispersion, compile WRF-Chem
#
state real - ikjftb tracer 1 - - -
state real tr17_1 ikjftb tracer 1 - irhusdf=(bdy_interp:dt) "tr17_1" "tr17_1" "Dimensionless"
state real tr17_2 ikjftb tracer 1 - irhusdf=(bdy_interp:dt) "tr17_2" "tr17_2" "Dimensionless"
state real tr17_3 ikjftb tracer 1 - irhusdf=(bdy_interp:dt) "tr17_3" "tr17_3" "Dimensionless"
state real tr17_4 ikjftb tracer 1 - irhusdf=(bdy_interp:dt) "tr17_4" "tr17_4" "Dimensionless"
state real tr17_5 ikjftb tracer 1 - irhusdf=(bdy_interp:dt) "tr17_5" "tr17_5" "Dimensionless"
state real tr17_6 ikjftb tracer 1 - irhusdf=(bdy_interp:dt) "tr17_6" "tr17_6" "Dimensionless"
state real tr17_7 ikjftb tracer 1 - irhusdf=(bdy_interp:dt) "tr17_7" "tr17_7" "Dimensionless"
state real tr17_8 ikjftb tracer 1 - irhusdf=(bdy_interp:dt) "tr17_8" "tr17_8" "Dimensionless"
state real BKBplm ikjftb tracer 1 - irhusdf=(bdy_interp:dt) "BKBplm" "BKBplm" "Dimensionless"
state real N_SLV ikjftb tracer 1 - irhusdf=(bdy_interp:dt) "N_SLV" "N_SLV" "Dimensionless"
state real S_SLV ikjftb tracer 1 - irhusdf=(bdy_interp:dt) "S_SLV" "S_SLV" "Dimensionless"
package tracer_test1 tracer_opt==2 - tracer:tr17_1,tr17_2,tr17_3,tr17_4,tr17_5,tr17_6,tr17_7,tr17_8,BKBplm,N_SLV,S_SLV
</textarea>
</div>
<div id="tab4" class="tab-pane fade">
<h3>module_initialize_real.F</h3>
<p><b style="color:green">WRFV3/dyn_em/module_initialize_real.F</b> contains information on how to initialize WRF in the real.exe executable.
Making these changes will initialize our tracer plume in WRF
<p>Here's a copy of my complete <a href="https://github.com/blaylockbk/Ute-WRF-User-Group/blob/master/Blaylock/add_tracer_plumes/module_initialize_real.F.bkb.tracer">module_initialize_real.F</a> file.
<p>Updates, if any here: <a href="https://github.com/blaylockbk/Ute_WRF/blob/master/modificaions/module_initialize_real.F.bkb.tracer"><i class="fab fa-github"></i> Github.</a>
<p>The changes made to the original WRF code, starting on line 3372 are shown below...
<textarea disabled>
! Creates an 8x8 size grid box plume in the center of the domain
!! If the tracer_opt is set to 2 in the namelist...
IF (config_flags%tracer_opt .eq. 2) THEN
!! j = j direction (south-north) i = i direction (west-east)
!! d = domain grid
!! s = starting point e = ending point
!! (Last gridpoint + First gridpoint)/2 = middle of domain, then +/- 4 creates a box 8 grid points wide.
DO j = (jde + jds)/2 - 4, (jde + jds)/2 + 4, 1
DO i = (ide + ids)/2 - 4, (ide + ids)/2 + 4, 1
!! IMPORTANT: The line below is required if you are running WRF in parallel.
!! t = tile grid. Parallel computing will break up your WRF code into tiles for faster computing.
!! Without the line below you will get a plume initialized on every tile (about the number of cores you run WRF on)
IF ( its .LE. i .and. ite .GE. i .and. jts .LE. j .and. jte .GE. j ) THEN
!! Now assign a value to the tracer variable with the grid point i,j
!! For the variable tr17_1, assign a value of 1. at grid point i, j.
!! The trick here, is that the variable name must be preceeded with "P_"
tracer(i, 1, j, P_tr17_1) = 1.
! tracer(i, 1, j, P_tr17_2) = 1.
! tracer(i, 1, j, P_tr17_3) = 1.
! tracer(i, 1, j, P_tr17_4) = 1.
! tracer(i, 1, j, P_tr17_5) = 1.
! tracer(i, 1, j, P_tr17_6) = 1.
! tracer(i, 1, j, P_tr17_7) = 1.
! tracer(i, 1, j, P_tr17_8) = 1.
! tracer(i, 1, j, P_BKBplm) = 1.
END IF
END DO
END DO
END IF
! Another Example:
! 5x15 Plume Line on the south end of the Salt Lake Valley
!(indexes valid for domain 2)
IF (config_flags%tracer_opt .eq. 2) THEN
DO j = jds + 198, jds + 203, 1
DO i = ids + 225, ids + 240, 1
IF ( its .LE. i .and. ite .GE. i .and. jts .LE. j .and. jte .GE. j ) THEN
tracer(i, 1, j, P_S_SLV) = 1.
END IF
END DO
END DO
END IF
! Another Example:
! 5x15 Plume Line on the north end of the Salt Lake Valley
! (indexes valid for domain 2)
IF (config_flags%tracer_opt .eq. 2) THEN
DO j = jds + 220, jds + 225, 1
DO i = ids + 215, ids + 230, 1
IF ( its .LE. i .and. ite .GE. i .and. jts .LE. j .and. jte .GE. j ) THEN
tracer(i, 1, j, P_N_SLV) = 1.
END IF
END DO
END DO
END IF
! Extra Test Plume in top right corner
! IF (config_flags%tracer_opt .eq. 2) THEN
! DO j = jde - 90, jde - 30, 1
! DO i = ide - 40, ide - 30, 1
! IF ( its .LE. i .and. ite .GE. i .and. jts .LE. j .and. jte .GE. j ) THEN
! tracer(i, 1, j, P_BKBplm) = 1.
! END IF
! END DO
! END DO
! END IF
!---------------------------------------------------------------------------------------
</textarea>
</div>
<div id="tab5" class="tab-pane fade">
<h3>solve_em.F</h3>
<p><b style="color:green">WRFV3/dyn_em/solve_em.F</b> contains information on how to create a continuous plume.
Making these changes will continue the plume each timestep in WRF.
<p>Here's a copy of my complete <a href="https://github.com/blaylockbk/Ute-WRF-User-Group/blob/master/Blaylock/add_tracer_plumes/solve_em.F.bkb.tracer">solve_em.F</a> file.
<p>Updates, if any here: <a href="https://github.com/blaylockbk/Ute_WRF/blob/master/modificaions/solve_em.F.bkb.tracer"><i class="fab fa-github"></i> Github.</a>
<p>The changes made to the original WRF code, starting on line 265 are shown below...
<p>This is very similar to the modifications made in module_initialize_real.F, but notice the KEY change from <b>its</b> to <b><i>ips</i></b> in the IF statement...
I think this is becuase of a change in how WRF separates the code in real and wrf
<textarea disabled>
!---------------- Brian Blaylock Tracers -------
IF ( config_flags%tracer_opt == 2 ) THEN
IF (grid%id == 2 ) THEN
DO j = jde - 90, jde - 30, 1
DO i = ide - 40, ide - 30, 1
IF (ips .LE. i .and. ipe .GE. i .and. jps .LE. j .and. jpe .GE. j ) THEN
tracer(i,1,j,P_BKBplm) = 1.
! tracer(225,1,198,P_S_SLV) = 1.
! tracer(215,1,220,P_N_SLV) = 1.
END IF
END DO
END DO
END IF
END IF
IF ( config_flags%tracer_opt == 2 ) THEN
IF (grid%id == 2 ) THEN
DO j = jds + 198, jds + 203, 1
DO i = ids + 225, ids + 240, 1
IF (ips .LE. i .and. ipe .GE. i .and. jps .LE. j .and. jpe .GE. j ) THEN
! tracer(i,1,j,P_BKBplm) = 1.
tracer(i,1,j,P_S_SLV) = 1.
! tracer(215,1,220,P_N_SLV) = 1.
END IF
END DO
END DO
END IF
END IF
IF ( config_flags%tracer_opt == 2 ) THEN
IF (grid%id == 2 ) THEN
DO j = jds + 220 , jds + 225, 1
DO i = ids + 215, ids + 230, 1
IF (ips .LE. i .and. ipe .GE. i .and. jps .LE. j .and. jpe .GE. j ) THEN
! tracer(i,1,j,P_BKBplm) = 1.
! tracer(225,1,198,P_S_SLV) = 1.
tracer(i,1,j,P_N_SLV) = 1.
END IF
END DO
END DO
END IF
END IF
!------------------------------------------------
</textarea>
<p>This will continue the tracer plume every time step.
<p style="color:red">Note: I've realized that this method artificially removes tracers. Tracers transported back
into the source location is automatically reset to 1. To fix this you'll have to add to the value already in the gird box,
so something like this: <i>tracer(225,1,198,P_S_SLV) = tracer(225,1,198,P_S_SLV) + 1</i>. Or mor generally <i>tracer(i,1,j,P_S_SLV)= tracer(i,1,j,P_S_SLV)+1</i>.
<hr>
<h3>Initlize Tracers after WRF begins</h3>
<p> It is possible to create a new "smoke puff" at specific intervals
rather than every time step (say, you want a new plume every hour).
I haven't got the periodic plume working yet, but here's
a clue in an email from Dave Gill...
<textarea style="height:110px" disabled>
!You can get the time in a few ways. For a fixed time step, if you know
!the time step (dt) and the number of tine steps (itimestep), then you are good to go.
300 grid%itimestep = grid%itimestep + 1
301 grid%dtbc = grid%dtbc + grid%dt
</textarea>
<p> Here is an approach to add a delayed tracer, but I haven't tested yet.
(Special thanks to Sudheer Bhimireddy for testing this approach)
<ol style="padding-left:60px">
<li>In module_initialize_real.F, set tracer value to zero (don't add a new tracer at the initial time)
<li>In solve_em.F, add a conditional statement to add tracers only after a certain timestep
<div class="alert alert-info">IF ( grid%itimestep .GE. tracer_time ) THEN<br>
! Release the tracers<br>
END IF
</div>
Where tracer_time is the number of time steps after model initlization.
(tracer_time = desired_spin-up_time(in seconds)/time_step(in seconds))
</ol>
</div>
<div id="tab6" class="tab-pane fade">
<h3>Increase Tracer Plume Output Frequency (or any other variable)</h3>
<p> The default in WRF is to output variables in the wrfout file at interval defined in the namelist options.
I output wrf variables every hour. But I want the tracer plume output at a higher frequency.
<p>In order to increase the frequency of WRF output for the plume, follow the directions
<a href="http://www2.mmm.ucar.edu/wrf/OnLineTutorial/Class_July2015/cases/Increase_freq_output_variables.php">here</a>.
<br>
<p><img align=right style="width:300px; padding-left:30px;" src = 'images/plume_loop.gif'>
The cyan image is an example of plume output at every hour. But we want the output every ten minutes.
<p> In order to output the plumes data at a higher frequency you have to change
the namelist options as outlined <a href="http://www2.mmm.ucar.edu/wrf/OnLineTutorial/Class_July2015/cases/Increase_freq_output_variables.php">
here</a>. I have added two new output streams. One that outputs every 12 hours (stream 23)
and one that outputs every 10 minutes (stream 24). Note: Steams can range from 0-24.
<p> I have created a file called "myoutfields_d01.txt" which tells WRF to write the T2 and tr17_1 to stream 24 and HGT
and LANDMASK to stream 23. Note: Do not include any spaces!
<textarea style="width:100%; height:40px;" disabled>
+:h:24:T2,tr17_1
+:h:23:HGT,LANDMASK
</textarea>
<p> In namelist.input I added these lines in the &time_control section:
<textarea style="width:100%; height:110px;" disabled>
iofields_filename = "myoutfields_d01.txt", ! Name of file that tells WRF what to output
io_form_auxhist24 = 2, ! Output stream 24 in netCDF format
auxhist24_interval = 10, ! Output stream 24 every 10 minutes
io_form_auxhist23 = 2, ! Output stream 23 in netCDF format
auxhist23_interval = 720, ! Output stream 23 every 12 hours
</textarea>
<p> Or, if you have two domains...
<textarea style="width:100%; height:110px;" disabled>
iofields_filename = "myoutfields_d01.txt", "myoutfields_d02.txt"
io_form_auxhist24 = 2,
auxhist24_interval = 10, 10,
io_form_auxhist23 = 2,
auxhist23_interval = 720, 720,
</textarea>
<p> When you run WRF with these options it will create two new netCDF files called
<i>auxhist23_d01_2015-06-18_00:00:00</i> and <i>auxhist24_d01_2015-06-18_00:00:00</i>. You can
view these in ncview.
</div>
<div id="tab7" class="tab-pane fade">
<h3>Example</h3>
<p>View code for creating images like the ones shown below
on <a href="https://github.com/blaylockbk/pyPlots_v2/tree/master/WRF-Tracers"><i class="fab fa-github"></i> GitHub</a>.
<br><br>
<video id="videoclip" style="height:50vh;" autoplay controls loop title="Time Lapse">
<source id="mp4video" src="https://home.chpc.utah.edu/~u0553130/MS/planeview_tracercomposite/NorthSouthTracers.mp4" type="video/mp4"/>
</video>
<br><br>
<video id="videoclip" style="width:80%;" autoplay controls loop title="Time Lapse">
<source id="mp4video" src="https://home.chpc.utah.edu/~u0553130/MS/crosssection/plumes_crosssection.mp4" type="video/mp4" />
</video>
</div>
</div>
<br>
<div class="panel panel-danger">
<div class="panel-body" align=center>
<small><i class="fa fa-book fa-fw" aria-hidden="true"></i>
This work was used in
<a style="color:#990000;font-weight:700;" href=http://journals.ametsoc.org/doi/abs/10.1175/JAMC-D-16-0216.1 target="_blank">Blaylock et al. 2017</a></small>
</div>
</div>
<script src="./js/site/siteclose.js"></script>
</body>
</html>