Line data Source code
1 : module cam_snapshot_common
2 : !--------------------------------------------------------
3 : ! The purpose of this module is to handle taking the "snapshot" of CAM data.
4 : !
5 : ! This module writes out ALL the state, tend and pbuf fields. It also includes the cam_in and cam_out
6 : ! fields which are used within CAM
7 : !--------------------------------------------------------
8 :
9 : use shr_kind_mod, only: r8 => shr_kind_r8
10 : use cam_history, only: addfld, add_default, outfld
11 : use cam_history, only: cam_history_snapshot_deactivate, cam_history_snapshot_activate
12 : use cam_history_support, only: horiz_only
13 : use cam_abortutils, only: endrun
14 : use physics_buffer, only: physics_buffer_desc, pbuf_get_index, pbuf_get_field, pbuf_get_field_name
15 : use physics_types, only: physics_state, physics_tend, physics_ptend
16 : use camsrfexch, only: cam_out_t, cam_in_t
17 : use ppgrid, only: pcols, begchunk, endchunk
18 : use constituents, only: pcnst
19 : use phys_control, only: phys_getopts
20 : use cam_logfile, only: iulog
21 :
22 : implicit none
23 :
24 : private
25 :
26 : public :: cam_snapshot_deactivate
27 : public :: cam_snapshot_all_outfld
28 : public :: cam_snapshot_ptend_outfld
29 : public :: snapshot_type
30 : public :: cam_state_snapshot_init
31 : public :: cam_cnst_snapshot_init
32 : public :: cam_tend_snapshot_init
33 : public :: cam_ptend_snapshot_init
34 : public :: cam_in_snapshot_init
35 : public :: cam_out_snapshot_init
36 : public :: cam_pbuf_snapshot_init
37 : public :: snapshot_addfld
38 :
39 : private :: snapshot_addfld_nd
40 : private :: state_snapshot_all_outfld
41 : private :: cnst_snapshot_all_outfld
42 : private :: tend_snapshot_all_outfld
43 : private :: cam_in_snapshot_all_outfld
44 : private :: cam_out_snapshot_all_outfld
45 : private :: cam_pbuf_snapshot_all_outfld
46 : private :: fill_pbuf_info
47 :
48 :
49 :
50 : ! This is the number of pbuf fields in the CAM code that are declared with the fieldname as opposed to being data driven.
51 : integer, parameter :: npbuf_all = 310
52 :
53 : type snapshot_type
54 : character(len=40) :: ddt_string
55 : character(len=256) :: standard_name
56 : character(len=20) :: dim_name
57 : character(len=8) :: units
58 : end type snapshot_type
59 :
60 : type snapshot_type_nd
61 : character(len=40) :: ddt_string
62 : character(len=256) :: standard_name
63 : character(len=20) :: dim_name(6) ! hardwired 6 potential dimensions in pbuf
64 : character(len=8) :: units
65 : end type snapshot_type_nd
66 :
67 : type pbuf_info_type
68 : character(len=40) :: name
69 : character(len=256) :: standard_name
70 : character(len=8) :: units
71 : character(len=100) :: dim_string(6) ! hardwired 6 potential dimensions in pbuf
72 : end type pbuf_info_type
73 :
74 : integer :: nstate_var
75 : integer :: ncnst_var
76 : integer :: ntend_var
77 : integer :: ncam_in_var
78 : integer :: ncam_out_var
79 : integer :: npbuf_var
80 :
81 : integer :: cam_snapshot_before_num, cam_snapshot_after_num
82 :
83 : ! Note the maximum number of variables for each type
84 : type (snapshot_type) :: state_snapshot(30)
85 : type (snapshot_type) :: cnst_snapshot(pcnst)
86 : type (snapshot_type) :: tend_snapshot(6)
87 : type (snapshot_type) :: cam_in_snapshot(30)
88 : type (snapshot_type) :: cam_out_snapshot(30)
89 : type (snapshot_type_nd) :: pbuf_snapshot(300)
90 :
91 : contains
92 :
93 0 : subroutine cam_snapshot_all_outfld(file_num, state, tend, cam_in, cam_out, pbuf)
94 :
95 : use time_manager, only: is_first_step
96 :
97 : !--------------------------------------------------------
98 : ! This subroutine does the outfld calls for ALL state, tend and pbuf fields. It also includes the cam_in and cam_out
99 : ! elements which are used within CAM
100 : !--------------------------------------------------------
101 :
102 : integer, intent(in) :: file_num
103 : type(physics_state), intent(in) :: state
104 : type(physics_tend), intent(in) :: tend
105 : type(cam_in_t), intent(in) :: cam_in
106 : type(cam_out_t), intent(in) :: cam_out
107 : type(physics_buffer_desc), pointer, intent(in) :: pbuf(:)
108 :
109 :
110 : integer :: lchnk
111 :
112 : ! Return if the first timestep as not all fields may be filled in and this will cause a core dump
113 0 : if (is_first_step()) return
114 :
115 : ! Return if not turned on
116 0 : if (cam_snapshot_before_num <= 0 .and. cam_snapshot_after_num <= 0) return ! No snapshot files are being requested
117 :
118 0 : lchnk = state%lchnk
119 :
120 : ! Write out all the state fields
121 0 : call state_snapshot_all_outfld(lchnk, file_num, state)
122 :
123 : ! Write out all the constituent fields
124 0 : call cnst_snapshot_all_outfld(lchnk, file_num, state%q)
125 :
126 : ! Write out all the tendency fields
127 0 : call tend_snapshot_all_outfld(lchnk, file_num, tend)
128 :
129 : ! Write out all the cam_in fields
130 0 : call cam_in_snapshot_all_outfld(lchnk, file_num, cam_in)
131 :
132 : ! Write out all the cam_out fields
133 0 : call cam_out_snapshot_all_outfld(lchnk, file_num, cam_out)
134 :
135 : ! Write out all the pbuf fields
136 0 : call cam_pbuf_snapshot_all_outfld(lchnk, file_num, pbuf)
137 :
138 0 : end subroutine cam_snapshot_all_outfld
139 :
140 1536 : subroutine cam_snapshot_deactivate()
141 :
142 : !--------------------------------------------------------
143 : ! This subroutine deactivates the printing of the snapshot before and after files
144 : ! Note - this needs to be done as add_default has been called to setup the proper
145 : ! outputting of the requested fields. The outfld calls will only write
146 : ! one file at a time (using the same name in both files), hence the writing
147 : ! needs to be turned off for all fields, and will be turned on individaully
148 : ! when needed.
149 : !--------------------------------------------------------
150 : integer :: i
151 :
152 : ! Return if not turned on
153 1536 : if (cam_snapshot_before_num <= 0 .and. cam_snapshot_after_num <= 0) return ! No snapshot files are being requested
154 :
155 0 : do i=1,nstate_var
156 0 : call cam_history_snapshot_deactivate(state_snapshot(i)%standard_name)
157 : end do
158 :
159 0 : do i=1,ncnst_var
160 0 : call cam_history_snapshot_deactivate(cnst_snapshot(i)%standard_name)
161 : end do
162 :
163 0 : do i=1,ntend_var
164 0 : call cam_history_snapshot_deactivate(tend_snapshot(i)%standard_name)
165 : end do
166 :
167 0 : do i=1,ncam_in_var
168 0 : call cam_history_snapshot_deactivate(cam_in_snapshot(i)%standard_name)
169 : end do
170 :
171 0 : do i=1,ncam_out_var
172 0 : call cam_history_snapshot_deactivate(cam_out_snapshot(i)%standard_name)
173 : end do
174 :
175 0 : do i=1,npbuf_var
176 0 : call cam_history_snapshot_deactivate(pbuf_snapshot(i)%standard_name)
177 : end do
178 :
179 0 : end subroutine cam_snapshot_deactivate
180 :
181 :
182 0 : subroutine cam_state_snapshot_init(cam_snapshot_before_num_in, cam_snapshot_after_num_in)
183 :
184 : !--------------------------------------------------------
185 : ! This subroutine does the addfld calls for state
186 : !--------------------------------------------------------
187 :
188 : integer,intent(in) :: cam_snapshot_before_num_in, cam_snapshot_after_num_in
189 :
190 0 : nstate_var = 0
191 :
192 0 : cam_snapshot_before_num = cam_snapshot_before_num_in
193 0 : cam_snapshot_after_num = cam_snapshot_after_num_in
194 :
195 : !--------------------------------------------------------
196 : ! Add the state variables to the output
197 : !--------------------------------------------------------
198 :
199 : call snapshot_addfld( nstate_var, state_snapshot, cam_snapshot_before_num, cam_snapshot_after_num, &
200 0 : 'state%ps', 'state_ps', 'Pa', horiz_only)
201 :
202 : call snapshot_addfld( nstate_var, state_snapshot, cam_snapshot_before_num, cam_snapshot_after_num, &
203 0 : 'state%psdry', 'state_psdry', 'Pa', horiz_only)
204 :
205 : call snapshot_addfld( nstate_var, state_snapshot, cam_snapshot_before_num, cam_snapshot_after_num, &
206 0 : 'state%phis', 'state_phis', 'm2/m2', horiz_only)
207 :
208 : call snapshot_addfld( nstate_var, state_snapshot, cam_snapshot_before_num, cam_snapshot_after_num, &
209 0 : 'state%t', 'state_t', 'K', 'lev')
210 :
211 : call snapshot_addfld( nstate_var, state_snapshot, cam_snapshot_before_num, cam_snapshot_after_num, &
212 0 : 'state%u', 'state_u', 'm s-1', 'lev')
213 :
214 : call snapshot_addfld( nstate_var, state_snapshot, cam_snapshot_before_num, cam_snapshot_after_num, &
215 0 : 'state%v', 'state_v', 'm s-1', 'lev')
216 :
217 : call snapshot_addfld( nstate_var, state_snapshot, cam_snapshot_before_num, cam_snapshot_after_num, &
218 0 : 'state%s', 'state_s', ' ', 'lev')
219 :
220 : call snapshot_addfld( nstate_var, state_snapshot, cam_snapshot_before_num, cam_snapshot_after_num, &
221 0 : 'state%omega', 'state_omega', 'Pa s-1', 'lev')
222 :
223 : call snapshot_addfld( nstate_var, state_snapshot, cam_snapshot_before_num, cam_snapshot_after_num, &
224 0 : 'state%pmid', 'state_pmid', 'Pa', 'lev')
225 :
226 : call snapshot_addfld( nstate_var, state_snapshot, cam_snapshot_before_num, cam_snapshot_after_num, &
227 0 : 'state%pmiddry', 'state_pmiddry', 'Pa', 'lev')
228 :
229 : call snapshot_addfld( nstate_var, state_snapshot, cam_snapshot_before_num, cam_snapshot_after_num, &
230 0 : 'state%pdel', 'state_pdel', 'Pa', 'lev')
231 :
232 : call snapshot_addfld( nstate_var, state_snapshot, cam_snapshot_before_num, cam_snapshot_after_num, &
233 0 : 'state%pdeldry', 'state_pdeldry', 'Pa', 'lev')
234 :
235 : call snapshot_addfld( nstate_var, state_snapshot, cam_snapshot_before_num, cam_snapshot_after_num, &
236 0 : 'state%rpdel', 'state_rpdel', 'Pa', 'lev')
237 :
238 : call snapshot_addfld( nstate_var, state_snapshot, cam_snapshot_before_num, cam_snapshot_after_num, &
239 0 : 'state%rpdeldry', 'state_rpdeldry', 'Pa', 'lev')
240 :
241 : call snapshot_addfld( nstate_var, state_snapshot, cam_snapshot_before_num, cam_snapshot_after_num, &
242 0 : 'state%lnpmid', 'state_lnpmid', 'unset', 'lev')
243 :
244 : call snapshot_addfld( nstate_var, state_snapshot, cam_snapshot_before_num, cam_snapshot_after_num, &
245 0 : 'state%lnpmiddry', 'state_lnpmiddry', 'unset', 'lev')
246 :
247 : call snapshot_addfld( nstate_var, state_snapshot, cam_snapshot_before_num, cam_snapshot_after_num, &
248 0 : 'state%exner', 'state_exner', 'unset', 'lev')
249 :
250 : call snapshot_addfld( nstate_var, state_snapshot, cam_snapshot_before_num, cam_snapshot_after_num, &
251 0 : 'state%zm', 'state_zm', 'm', 'lev')
252 :
253 : call snapshot_addfld( nstate_var, state_snapshot, cam_snapshot_before_num, cam_snapshot_after_num, &
254 0 : 'state%pint', 'state_pint', 'Pa', 'ilev')
255 :
256 : call snapshot_addfld( nstate_var, state_snapshot, cam_snapshot_before_num, cam_snapshot_after_num, &
257 0 : 'state%pintdry', 'state_pintdry', 'Pa', 'ilev')
258 :
259 : call snapshot_addfld( nstate_var, state_snapshot, cam_snapshot_before_num, cam_snapshot_after_num, &
260 0 : 'state%lnpint', 'state_lnpint', 'unset', 'ilev')
261 :
262 : call snapshot_addfld( nstate_var, state_snapshot, cam_snapshot_before_num, cam_snapshot_after_num, &
263 0 : 'state%lnpintdry', 'state_lnpintdry', 'unset', 'ilev')
264 :
265 : call snapshot_addfld( nstate_var, state_snapshot, cam_snapshot_before_num, cam_snapshot_after_num, &
266 0 : 'state%zi', 'state_zi', 'm', 'ilev')
267 :
268 : call snapshot_addfld( nstate_var, state_snapshot, cam_snapshot_before_num, cam_snapshot_after_num, &
269 0 : 'state%te_ini_phys', 'state_te_ini_phys', 'unset', horiz_only)
270 :
271 : call snapshot_addfld( nstate_var, state_snapshot, cam_snapshot_before_num, cam_snapshot_after_num, &
272 0 : 'state%te_cur_phys', 'state_te_cur_phys', 'unset', horiz_only)
273 :
274 : call snapshot_addfld( nstate_var, state_snapshot, cam_snapshot_before_num, cam_snapshot_after_num, &
275 0 : 'state%tw_ini', 'state_tw_ini', 'unset', horiz_only)
276 :
277 : call snapshot_addfld( nstate_var, state_snapshot, cam_snapshot_before_num, cam_snapshot_after_num, &
278 0 : 'state%tw_cur', 'state_tw_cur', 'unset', horiz_only)
279 :
280 : call snapshot_addfld( nstate_var, state_snapshot, cam_snapshot_before_num, cam_snapshot_after_num, &
281 0 : 'state%te_ini_dyn', 'state_te_ini_dyn', 'unset', horiz_only)
282 :
283 : call snapshot_addfld( nstate_var, state_snapshot, cam_snapshot_before_num, cam_snapshot_after_num, &
284 0 : 'state%te_cur_dyn', 'state_te_cur_dyn', 'unset', horiz_only)
285 :
286 : call snapshot_addfld( nstate_var, state_snapshot, cam_snapshot_before_num, cam_snapshot_after_num, &
287 0 : 'air_composition_cp_or_cv_dycore', 'cp_or_cv_dycore', 'J kg-1 K-1', 'lev')
288 :
289 0 : end subroutine cam_state_snapshot_init
290 :
291 0 : subroutine cam_cnst_snapshot_init(cam_snapshot_before_num, cam_snapshot_after_num)
292 :
293 : !--------------------------------------------------------
294 : ! This subroutine does the addfld calls for state constituent (q) fields
295 : !--------------------------------------------------------
296 :
297 : use constituents, only: cnst_name, cnst_longname
298 :
299 : integer, intent(in) :: cam_snapshot_before_num, cam_snapshot_after_num
300 :
301 : !--------------------------------------------------------
302 : ! Add the cnst variables to the output
303 : !--------------------------------------------------------
304 :
305 0 : ncnst_var = 0 ! Updated inside snapshot_addfld
306 :
307 0 : do while (ncnst_var < pcnst)
308 : call snapshot_addfld(ncnst_var, cnst_snapshot, cam_snapshot_before_num, &
309 0 : cam_snapshot_after_num, cnst_name(ncnst_var+1), &
310 0 : trim('cnst_'//cnst_name(ncnst_var+1)), 'kg kg-1', 'lev')
311 : end do
312 :
313 0 : end subroutine cam_cnst_snapshot_init
314 :
315 0 : subroutine cam_tend_snapshot_init(cam_snapshot_before_num, cam_snapshot_after_num)
316 :
317 : !--------------------------------------------------------
318 : ! This subroutine does the addfld calls for tend fields.
319 : !--------------------------------------------------------
320 :
321 : integer,intent(in) :: cam_snapshot_before_num, cam_snapshot_after_num
322 :
323 0 : ntend_var = 0
324 :
325 : !--------------------------------------------------------
326 : ! Add the physics_tend variables to the output
327 : !--------------------------------------------------------
328 :
329 : call snapshot_addfld( ntend_var, tend_snapshot, cam_snapshot_before_num, cam_snapshot_after_num, &
330 0 : 'tend%dtdt', 'tend_dtdt', 'K s-1', 'lev')
331 :
332 : call snapshot_addfld( ntend_var, tend_snapshot, cam_snapshot_before_num, cam_snapshot_after_num, &
333 0 : 'tend%dudt', 'tend_dudt', '', 'lev')
334 :
335 : call snapshot_addfld( ntend_var, tend_snapshot, cam_snapshot_before_num, cam_snapshot_after_num, &
336 0 : 'tend%dvdt', 'tend_dvdt', '', 'lev')
337 :
338 : call snapshot_addfld( ntend_var, tend_snapshot, cam_snapshot_before_num, cam_snapshot_after_num, &
339 0 : 'tend%flx_net', 'tend_flx_net', '', horiz_only)
340 :
341 : call snapshot_addfld( ntend_var, tend_snapshot, cam_snapshot_before_num, cam_snapshot_after_num, &
342 0 : 'tend%te_tnd', 'tend_te_tnd', '', horiz_only)
343 :
344 : call snapshot_addfld( ntend_var, tend_snapshot, cam_snapshot_before_num, cam_snapshot_after_num, &
345 0 : 'tend%tw_tnd', 'tend_tw_tnd', '', horiz_only)
346 :
347 0 : end subroutine cam_tend_snapshot_init
348 :
349 0 : subroutine cam_ptend_snapshot_init(cam_snapshot_after_num)
350 : use constituents, only: cnst_name, cnst_longname
351 :
352 : !--------------------------------------------------------
353 : ! This subroutine does the addfld calls for ptend fields.
354 : !--------------------------------------------------------
355 :
356 : integer,intent(in) :: cam_snapshot_after_num
357 :
358 : integer :: mcnst
359 : character(len=64) :: fname
360 : character(len=128) :: lname
361 : character(len=32) :: cam_take_snapshot_before
362 : character(len=32) :: cam_take_snapshot_after
363 :
364 : call phys_getopts(cam_take_snapshot_before_out = cam_take_snapshot_before, &
365 0 : cam_take_snapshot_after_out = cam_take_snapshot_after)
366 :
367 0 : if (trim(cam_take_snapshot_before) == trim(cam_take_snapshot_after)) then
368 :
369 : !--------------------------------------------------------
370 : ! Add the physics_ptend variables to the output
371 : !--------------------------------------------------------
372 :
373 : call addfld('ptend_s', (/ 'lev' /), 'I', 'J kg-1 s-1', &
374 0 : 'heating rate snapshot')
375 0 : call add_default('ptend_s', cam_snapshot_after_num, ' ')
376 :
377 : call addfld('ptend_u', (/ 'lev' /), 'I', 'm s-1 s-1', &
378 0 : 'momentum tendency snapshot')
379 0 : call add_default('ptend_u', cam_snapshot_after_num, ' ')
380 :
381 : call addfld('ptend_v', (/ 'lev' /), 'I', 'm s-1 s-1', &
382 0 : 'momentum tendency snapshot')
383 0 : call add_default('ptend_v', cam_snapshot_after_num, ' ')
384 :
385 : call addfld('ptend_hflux_srf', horiz_only, 'I', 'W m-2', &
386 0 : 'net zonal stress at surface snapshot')
387 0 : call add_default('ptend_hflux_srf', cam_snapshot_after_num, ' ')
388 :
389 : call addfld('ptend_hflux_top', horiz_only, 'I', 'W m-2', &
390 0 : 'net zonal stress at top of model snapshot')
391 0 : call add_default('ptend_hflux_top', cam_snapshot_after_num, ' ')
392 :
393 : call addfld('ptend_taux_srf', horiz_only, 'I', 'Pa', &
394 0 : 'net meridional stress at surface snapshot')
395 0 : call add_default('ptend_taux_srf', cam_snapshot_after_num, ' ')
396 :
397 : call addfld('ptend_taux_top', horiz_only, 'I', 'Pa', &
398 0 : 'net zonal stress at top of model snapshot')
399 0 : call add_default('ptend_taux_top', cam_snapshot_after_num, ' ')
400 :
401 : call addfld('ptend_tauy_srf', horiz_only, 'I', 'Pa', &
402 0 : 'net meridional stress at surface snapshot')
403 0 : call add_default('ptend_tauy_srf', cam_snapshot_after_num, ' ')
404 :
405 : call addfld('ptend_tauy_top', horiz_only, 'I', 'Pa', &
406 0 : 'net meridional stress at top of model snapshot')
407 0 : call add_default('ptend_tauy_top', cam_snapshot_after_num, ' ')
408 :
409 0 : do mcnst = 1, pcnst
410 0 : fname = 'ptend_'//trim(cnst_name(mcnst))
411 0 : lname = 'tendency of '//trim(cnst_longname(mcnst))
412 0 : call addfld(trim(fname), (/ 'lev' /), 'I', 'kg kg-1 s-1', trim(lname))
413 0 : call add_default(trim(fname), cam_snapshot_after_num, ' ')
414 :
415 0 : fname = 'ptend_cflx_srf_'//trim(cnst_name(mcnst))
416 0 : lname = 'flux of '//trim(cnst_longname(mcnst))//' at surface snapshot'
417 0 : call addfld(trim(fname), horiz_only, 'I', 'kg m-2 s-1', trim(lname))
418 0 : call add_default(trim(fname), cam_snapshot_after_num, ' ')
419 :
420 0 : fname = 'ptend_cflx_top_'//trim(cnst_name(mcnst))
421 0 : lname = 'flux of '//trim(cnst_longname(mcnst))//' at top of model snapshot'
422 0 : call addfld(trim(fname), horiz_only, 'I', 'kg m-2 s-1', trim(lname))
423 0 : call add_default(trim(fname), cam_snapshot_after_num, ' ')
424 : end do
425 :
426 : end if
427 :
428 0 : end subroutine cam_ptend_snapshot_init
429 :
430 0 : subroutine cam_in_snapshot_init(cam_snapshot_before_num, cam_snapshot_after_num, cam_in)
431 :
432 : !--------------------------------------------------------
433 : ! This subroutine does the addfld calls for cam_in fields
434 : !--------------------------------------------------------
435 :
436 : type(cam_in_t), intent(in) :: cam_in
437 :
438 : integer,intent(in) :: cam_snapshot_before_num, cam_snapshot_after_num
439 :
440 0 : ncam_in_var = 0
441 :
442 : !--------------------------------------------------------
443 : ! Add the state variables to the output
444 : !--------------------------------------------------------
445 :
446 : call snapshot_addfld( ncam_in_var, cam_in_snapshot, cam_snapshot_before_num, cam_snapshot_after_num, &
447 0 : 'cam_in%landfrac', 'cam_in_landfrac', 'unset', horiz_only)
448 :
449 : call snapshot_addfld( ncam_in_var, cam_in_snapshot, cam_snapshot_before_num, cam_snapshot_after_num, &
450 0 : 'cam_in%ocnfrac', 'cam_in_ocnfrac', 'unset', horiz_only)
451 :
452 : call snapshot_addfld( ncam_in_var, cam_in_snapshot, cam_snapshot_before_num, cam_snapshot_after_num, &
453 0 : 'cam_in%snowhland', 'cam_in_snowhland', 'unset', horiz_only)
454 :
455 : call snapshot_addfld( ncam_in_var, cam_in_snapshot, cam_snapshot_before_num, cam_snapshot_after_num, &
456 0 : 'cam_in%ts', 'cam_in_ts', 'unset', horiz_only)
457 :
458 : call snapshot_addfld( ncam_in_var, cam_in_snapshot, cam_snapshot_before_num, cam_snapshot_after_num, &
459 0 : 'cam_in%sst', 'cam_in_sst', 'unset', horiz_only)
460 :
461 : call snapshot_addfld( ncam_in_var, cam_in_snapshot, cam_snapshot_before_num, cam_snapshot_after_num, &
462 0 : 'cam_in%icefrac', 'cam_in_icefrac', 'unset', horiz_only)
463 :
464 : call snapshot_addfld( ncam_in_var, cam_in_snapshot, cam_snapshot_before_num, cam_snapshot_after_num, &
465 0 : 'cam_in%shf', 'cam_in_shf', 'unset', horiz_only)
466 :
467 : call snapshot_addfld( ncam_in_var, cam_in_snapshot, cam_snapshot_before_num, cam_snapshot_after_num, &
468 0 : 'cam_in%cflx', 'cam_in_cflx', 'unset', horiz_only)
469 :
470 : call snapshot_addfld( ncam_in_var, cam_in_snapshot, cam_snapshot_before_num, cam_snapshot_after_num, &
471 0 : 'cam_in%wsx', 'cam_in_wsx', 'unset', horiz_only)
472 :
473 : call snapshot_addfld( ncam_in_var, cam_in_snapshot, cam_snapshot_before_num, cam_snapshot_after_num, &
474 0 : 'cam_in%wsy', 'cam_in_wsy', 'unset', horiz_only)
475 :
476 : call snapshot_addfld( ncam_in_var, cam_in_snapshot, cam_snapshot_before_num, cam_snapshot_after_num, &
477 0 : 'cam_in%asdif', 'cam_in_asdif', 'unset', horiz_only)
478 :
479 : call snapshot_addfld( ncam_in_var, cam_in_snapshot, cam_snapshot_before_num, cam_snapshot_after_num, &
480 0 : 'cam_in%aldif', 'cam_in_aldif', 'unset', horiz_only)
481 :
482 : call snapshot_addfld( ncam_in_var, cam_in_snapshot, cam_snapshot_before_num, cam_snapshot_after_num, &
483 0 : 'cam_in%lwup', 'cam_in_lwup', 'unset', horiz_only)
484 :
485 : call snapshot_addfld( ncam_in_var, cam_in_snapshot, cam_snapshot_before_num, cam_snapshot_after_num, &
486 0 : 'cam_in%asdir', 'cam_in_asdir', 'unset', horiz_only)
487 :
488 : call snapshot_addfld( ncam_in_var, cam_in_snapshot, cam_snapshot_before_num, cam_snapshot_after_num, &
489 0 : 'cam_in%aldir', 'cam_in_aldir', 'unset', horiz_only)
490 :
491 0 : if (associated (cam_in%meganflx)) &
492 : call snapshot_addfld( ncam_in_var, cam_in_snapshot, cam_snapshot_before_num, cam_snapshot_after_num, &
493 0 : 'cam_in%meganflx', 'cam_in_meganflx', 'unset', horiz_only)
494 :
495 0 : if (associated (cam_in%fireflx)) &
496 : call snapshot_addfld( ncam_in_var, cam_in_snapshot, cam_snapshot_before_num, cam_snapshot_after_num, &
497 0 : 'cam_in%fireflx', 'cam_in_fireflx', 'unset', horiz_only)
498 :
499 0 : if (associated (cam_in%fireztop)) &
500 : call snapshot_addfld( ncam_in_var, cam_in_snapshot, cam_snapshot_before_num, cam_snapshot_after_num, &
501 0 : 'cam_in%fireztop', 'cam_in_fireztop', 'unset', horiz_only)
502 :
503 0 : if (associated (cam_in%depvel)) &
504 : call snapshot_addfld( ncam_in_var, cam_in_snapshot, cam_snapshot_before_num, cam_snapshot_after_num, &
505 0 : 'cam_in%depvel', 'cam_in_depvel', 'unset', horiz_only)
506 :
507 : call snapshot_addfld( ncam_in_var, cam_in_snapshot, cam_snapshot_before_num, cam_snapshot_after_num, &
508 0 : 'cam_in%lhf', 'cam_in_lhf', 'unset', horiz_only)
509 :
510 0 : if (associated (cam_in%fv)) &
511 : call snapshot_addfld( ncam_in_var, cam_in_snapshot, cam_snapshot_before_num, cam_snapshot_after_num, &
512 0 : 'cam_in%fv', 'cam_in_fv', 'unset', horiz_only)
513 :
514 0 : if (associated (cam_in%ram1)) &
515 : call snapshot_addfld( ncam_in_var, cam_in_snapshot, cam_snapshot_before_num, cam_snapshot_after_num, &
516 0 : 'cam_in%ram1', 'cam_in_ram1', 'unset', horiz_only)
517 :
518 0 : if (associated (cam_in%dstflx)) &
519 : call snapshot_addfld( ncam_in_var, cam_in_snapshot, cam_snapshot_before_num, cam_snapshot_after_num, &
520 0 : 'cam_in%dstflx', 'cam_in_dstflx', 'unset', horiz_only)
521 :
522 0 : end subroutine cam_in_snapshot_init
523 :
524 0 : subroutine cam_out_snapshot_init(cam_snapshot_before_num, cam_snapshot_after_num, cam_out)
525 :
526 : !--------------------------------------------------------
527 : ! This subroutine does the addfld calls for cam_out fields
528 : !--------------------------------------------------------
529 :
530 : type(cam_out_t), intent(in) :: cam_out
531 :
532 : integer, intent(in) :: cam_snapshot_before_num, cam_snapshot_after_num
533 :
534 0 : ncam_out_var = 0
535 :
536 : !--------------------------------------------------------
537 : ! Add the state variables to the output
538 : !--------------------------------------------------------
539 :
540 : call snapshot_addfld( ncam_out_var, cam_out_snapshot, cam_snapshot_before_num, cam_snapshot_after_num, &
541 0 : 'cam_out%precc', 'cam_out_precc', 'm s-1', horiz_only)
542 :
543 : call snapshot_addfld( ncam_out_var, cam_out_snapshot, cam_snapshot_before_num, cam_snapshot_after_num, &
544 0 : 'cam_out%precl', 'cam_out_precl', 'm s-1', horiz_only)
545 :
546 : call snapshot_addfld( ncam_out_var, cam_out_snapshot, cam_snapshot_before_num, cam_snapshot_after_num, &
547 0 : 'cam_out%precsc', 'cam_out_precsc', 'm s-1', horiz_only)
548 :
549 : call snapshot_addfld( ncam_out_var, cam_out_snapshot, cam_snapshot_before_num, cam_snapshot_after_num, &
550 0 : 'cam_out%precsl', 'cam_out_precsl', 'm s-1', horiz_only)
551 :
552 0 : if (associated(cam_out%nhx_nitrogen_flx)) &
553 : call snapshot_addfld( ncam_out_var, cam_out_snapshot, cam_snapshot_before_num, cam_snapshot_after_num, &
554 0 : 'cam_out%nhx_nitrogen_flx', 'cam_out_nhx_nitrogen_flx', 'kgN m2-1 sec-1', horiz_only)
555 :
556 0 : if (associated(cam_out%noy_nitrogen_flx)) &
557 : call snapshot_addfld( ncam_out_var, cam_out_snapshot, cam_snapshot_before_num, cam_snapshot_after_num, &
558 0 : 'cam_out%noy_nitrogen_flx', 'cam_out_noy_nitrogen_flx', 'kgN m2-1 sec-1', horiz_only)
559 :
560 : call snapshot_addfld( ncam_out_var, cam_out_snapshot, cam_snapshot_before_num, cam_snapshot_after_num, &
561 0 : 'cam_out%bcphodry', 'cam_out_bcphodry', 'kg m-2 s-1', horiz_only)
562 :
563 : call snapshot_addfld( ncam_out_var, cam_out_snapshot, cam_snapshot_before_num, cam_snapshot_after_num, &
564 0 : 'cam_out%bcphidry', 'cam_out_bcphidry', 'kg m-2 s-1', horiz_only)
565 :
566 : call snapshot_addfld( ncam_out_var, cam_out_snapshot, cam_snapshot_before_num, cam_snapshot_after_num, &
567 0 : 'cam_out%ocphodry', 'cam_out_ocphodry', 'kg m-2 s-1', horiz_only)
568 :
569 : call snapshot_addfld( ncam_out_var, cam_out_snapshot, cam_snapshot_before_num, cam_snapshot_after_num, &
570 0 : 'cam_out%ocphidry', 'cam_out_ocphidry', 'kg m-2 s-1', horiz_only)
571 :
572 : call snapshot_addfld( ncam_out_var, cam_out_snapshot, cam_snapshot_before_num, cam_snapshot_after_num, &
573 0 : 'cam_out%bcphiwet', 'cam_out_bcphiwet', 'kg m-2 s-1', horiz_only)
574 :
575 : call snapshot_addfld( ncam_out_var, cam_out_snapshot, cam_snapshot_before_num, cam_snapshot_after_num, &
576 0 : 'cam_out%ocphiwet', 'cam_out_ocphiwet', 'kg m-2 s-1', horiz_only)
577 :
578 : call snapshot_addfld( ncam_out_var, cam_out_snapshot, cam_snapshot_before_num, cam_snapshot_after_num, &
579 0 : 'cam_out%dstwet1', 'cam_out_dstwet1', 'kg m-2 s-1', horiz_only)
580 :
581 : call snapshot_addfld( ncam_out_var, cam_out_snapshot, cam_snapshot_before_num, cam_snapshot_after_num, &
582 0 : 'cam_out%dstwet2', 'cam_out_dstwet2', 'kg m-2 s-1', horiz_only)
583 :
584 : call snapshot_addfld( ncam_out_var, cam_out_snapshot, cam_snapshot_before_num, cam_snapshot_after_num, &
585 0 : 'cam_out%dstwet3', 'cam_out_dstwet3', 'kg m-2 s-1', horiz_only)
586 :
587 : call snapshot_addfld( ncam_out_var, cam_out_snapshot, cam_snapshot_before_num, cam_snapshot_after_num, &
588 0 : 'cam_out%dstwet4', 'cam_out_dstwet4', 'kg m-2 s-1', horiz_only)
589 :
590 : call snapshot_addfld( ncam_out_var, cam_out_snapshot, cam_snapshot_before_num, cam_snapshot_after_num, &
591 0 : 'cam_out%dstdry1', 'cam_out_dstdry1', 'kg m-2 s-1', horiz_only)
592 :
593 : call snapshot_addfld( ncam_out_var, cam_out_snapshot, cam_snapshot_before_num, cam_snapshot_after_num, &
594 0 : 'cam_out%dstdry2', 'cam_out_dstdry2', 'kg m-2 s-1', horiz_only)
595 :
596 : call snapshot_addfld( ncam_out_var, cam_out_snapshot, cam_snapshot_before_num, cam_snapshot_after_num, &
597 0 : 'cam_out%dstdry3', 'cam_out_dstdry3', 'kg m-2 s-1', horiz_only)
598 :
599 : call snapshot_addfld( ncam_out_var, cam_out_snapshot, cam_snapshot_before_num, cam_snapshot_after_num, &
600 0 : 'cam_out%dstdry4', 'cam_out_dstdry4', 'kg m-2 s-1', horiz_only)
601 :
602 : call snapshot_addfld( ncam_out_var, cam_out_snapshot, cam_snapshot_before_num, cam_snapshot_after_num, &
603 0 : 'cam_out%sols', 'cam_out_sols', 'W m-2', horiz_only)
604 :
605 : call snapshot_addfld( ncam_out_var, cam_out_snapshot, cam_snapshot_before_num, cam_snapshot_after_num, &
606 0 : 'cam_out%soll', 'cam_out_soll', 'W m-2', horiz_only)
607 :
608 : call snapshot_addfld( ncam_out_var, cam_out_snapshot, cam_snapshot_before_num, cam_snapshot_after_num, &
609 0 : 'cam_out%solsd', 'cam_out_solsd', 'W m-2', horiz_only)
610 :
611 : call snapshot_addfld( ncam_out_var, cam_out_snapshot, cam_snapshot_before_num, cam_snapshot_after_num, &
612 0 : 'cam_out%solld', 'cam_out_solld', 'W m-2', horiz_only)
613 :
614 : call snapshot_addfld( ncam_out_var, cam_out_snapshot, cam_snapshot_before_num, cam_snapshot_after_num, &
615 0 : 'cam_out%netsw', 'cam_out_netsw', 'unset', horiz_only)
616 :
617 0 : end subroutine cam_out_snapshot_init
618 :
619 0 : subroutine cam_pbuf_snapshot_init(cam_snapshot_before_num, cam_snapshot_after_num, pbuf)
620 :
621 : !--------------------------------------------------------
622 : ! This subroutine does the addfld calls for pbuf fields.
623 : !--------------------------------------------------------
624 :
625 : use physics_buffer, only: pbuf_get_dim_strings
626 :
627 : integer, intent(in) :: cam_snapshot_before_num, cam_snapshot_after_num
628 : type(physics_buffer_desc), intent(in) :: pbuf(:)
629 :
630 : integer :: i, j, npbuf
631 0 : type(pbuf_info_type) :: pbuf_info(size(pbuf))
632 0 : character(len=40) :: const_cname(ncnst_var)
633 0 : character(len=40) :: dim_strings(size(pbuf),6) ! Hardwired 6 potential dimensions in pbuf
634 :
635 0 : npbuf = size(pbuf(:))
636 :
637 : !--------------------------------------------------------
638 : ! fill the name, standard name and units for pbuf_info
639 : !--------------------------------------------------------
640 :
641 0 : call fill_pbuf_info(pbuf_info, pbuf, const_cname)
642 :
643 : !--------------------------------------------------------
644 : ! Determine the indices for the addfld call based on the dimensions in the pbuf
645 : !--------------------------------------------------------
646 :
647 0 : call pbuf_get_dim_strings(pbuf, dim_strings)
648 0 : do i=1, npbuf
649 : ! If the second dimension is empty, then this is a horiz_only field
650 0 : if (trim(dim_strings(i,2)) == '') then
651 0 : pbuf_info(i)%dim_string(1) = horiz_only
652 : else
653 : ! The first dimension is the horizontal dimension and should not be used in the addfld call
654 0 : do j=2,6
655 0 : pbuf_info(i)%dim_string(j-1) = dim_strings(i,j)
656 : end do
657 : end if
658 : end do
659 :
660 : !--------------------------------------------------------
661 : ! Now that all of the information for the pbufs is stored, call the addfld
662 : !--------------------------------------------------------
663 0 : npbuf_var = 0 ! Updated inside snapshot_addfld
664 :
665 0 : do while (npbuf_var < npbuf)
666 : call snapshot_addfld_nd( npbuf_var, pbuf_snapshot, cam_snapshot_before_num, cam_snapshot_after_num, &
667 0 : pbuf_info(npbuf_var+1)%name, pbuf_info(npbuf_var+1)%standard_name, pbuf_info(npbuf_var+1)%units,&
668 0 : pbuf_info(npbuf_var+1)%dim_string)
669 : end do
670 :
671 0 : end subroutine cam_pbuf_snapshot_init
672 :
673 0 : subroutine snapshot_addfld_nd(nddt_var, ddt_snapshot, cam_snapshot_before_num, cam_snapshot_after_num,&
674 0 : ddt_string, standard_name, units, dimension_string)
675 :
676 : integer, intent(inout) :: nddt_var
677 : type (snapshot_type_nd), intent(inout) :: ddt_snapshot(:)
678 :
679 :
680 : integer, intent(in) :: cam_snapshot_before_num
681 : integer, intent(in) :: cam_snapshot_after_num
682 : character(len=*), intent(in) :: ddt_string
683 : character(len=*), intent(in) :: standard_name
684 : character(len=*), intent(in) :: units
685 : character(len=*), intent(in) :: dimension_string(:)
686 :
687 : integer :: ndims
688 :
689 0 : nddt_var=nddt_var+1
690 :
691 0 : if (nddt_var > size(ddt_snapshot)) &
692 0 : call endrun(' ERROR in snapshot_addfld: ddt_snapshot array not allocated large enough')
693 :
694 0 : ndims = count(dimension_string /= '')
695 :
696 0 : if (trim(dimension_string(1)) == horiz_only) then
697 0 : call addfld(standard_name, horiz_only, 'I', units, standard_name)
698 : else
699 0 : call addfld(standard_name, dimension_string(1:ndims), 'I', units, standard_name)
700 : end if
701 0 : if (cam_snapshot_before_num > 0) call add_default(standard_name, cam_snapshot_before_num, ' ')
702 0 : if (cam_snapshot_after_num > 0) call add_default(standard_name, cam_snapshot_after_num, ' ')
703 :
704 0 : ddt_snapshot(nddt_var)%ddt_string = ddt_string
705 0 : ddt_snapshot(nddt_var)%standard_name = standard_name
706 0 : ddt_snapshot(nddt_var)%dim_name(:) = dimension_string(:)
707 0 : ddt_snapshot(nddt_var)%units = units
708 :
709 :
710 0 : end subroutine snapshot_addfld_nd
711 :
712 0 : subroutine snapshot_addfld(nddt_var, ddt_snapshot, cam_snapshot_before_num, cam_snapshot_after_num,&
713 : ddt_string, standard_name, units, dimension_string)
714 :
715 : integer, intent(inout) :: nddt_var
716 : type (snapshot_type), intent(inout) :: ddt_snapshot(:)
717 :
718 :
719 : integer, intent(in) :: cam_snapshot_before_num
720 : integer, intent(in) :: cam_snapshot_after_num
721 : character(len=*), intent(in) :: ddt_string
722 : character(len=*), intent(in) :: standard_name
723 : character(len=*), intent(in) :: units
724 : character(len=*), intent(in) :: dimension_string
725 :
726 :
727 0 : nddt_var=nddt_var+1
728 :
729 0 : if (nddt_var > size(ddt_snapshot)) &
730 0 : call endrun(' ERROR in snapshot_addfld: ddt_snapshot array not allocated large enough')
731 :
732 0 : call addfld(standard_name, dimension_string, 'I', units, standard_name)
733 0 : if (cam_snapshot_before_num > 0) call add_default(standard_name, cam_snapshot_before_num, ' ')
734 0 : if (cam_snapshot_after_num > 0) call add_default(standard_name, cam_snapshot_after_num, ' ')
735 :
736 0 : ddt_snapshot(nddt_var)%ddt_string = ddt_string
737 0 : ddt_snapshot(nddt_var)%standard_name = standard_name
738 0 : ddt_snapshot(nddt_var)%dim_name = dimension_string
739 0 : ddt_snapshot(nddt_var)%units = units
740 :
741 :
742 0 : end subroutine snapshot_addfld
743 :
744 0 : subroutine state_snapshot_all_outfld(lchnk, file_num, state)
745 :
746 : use physics_types, only: phys_te_idx, dyn_te_idx
747 : use air_composition, only: cp_or_cv_dycore
748 :
749 : integer, intent(in) :: lchnk
750 : integer, intent(in) :: file_num
751 : type(physics_state), intent(in) :: state
752 :
753 : integer :: i
754 :
755 0 : do i=1, nstate_var
756 :
757 : ! Turn on the writing for only the requested tape (file_num)
758 0 : call cam_history_snapshot_activate(trim(state_snapshot(i)%standard_name), file_num)
759 :
760 : ! Select the state field which is being written
761 : select case(state_snapshot(i)%ddt_string)
762 :
763 : case ('state%ps')
764 0 : call outfld(state_snapshot(i)%standard_name, state%ps, pcols, lchnk)
765 :
766 : case ('state%psdry')
767 0 : call outfld(state_snapshot(i)%standard_name, state%psdry, pcols, lchnk)
768 :
769 : case ('state%phis')
770 0 : call outfld(state_snapshot(i)%standard_name, state%phis, pcols, lchnk)
771 :
772 : case ('state%t')
773 0 : call outfld(state_snapshot(i)%standard_name, state%t, pcols, lchnk)
774 :
775 : case ('state%u')
776 0 : call outfld(state_snapshot(i)%standard_name, state%u, pcols, lchnk)
777 :
778 : case ('state%v')
779 0 : call outfld(state_snapshot(i)%standard_name, state%v, pcols, lchnk)
780 :
781 : case ('state%s')
782 0 : call outfld(state_snapshot(i)%standard_name, state%s, pcols, lchnk)
783 :
784 : case ('state%omega')
785 0 : call outfld(state_snapshot(i)%standard_name, state%omega, pcols, lchnk)
786 :
787 : case ('state%pmid')
788 0 : call outfld(state_snapshot(i)%standard_name, state%pmid, pcols, lchnk)
789 :
790 : case ('state%pmiddry')
791 0 : call outfld(state_snapshot(i)%standard_name, state%pmiddry, pcols, lchnk)
792 :
793 : case ('state%pdel')
794 0 : call outfld(state_snapshot(i)%standard_name, state%pdel, pcols, lchnk)
795 :
796 : case ('state%pdeldry')
797 0 : call outfld(state_snapshot(i)%standard_name, state%pdeldry, pcols, lchnk)
798 :
799 : case ('state%rpdel')
800 0 : call outfld(state_snapshot(i)%standard_name, state%rpdel, pcols, lchnk)
801 :
802 : case ('state%rpdeldry')
803 0 : call outfld(state_snapshot(i)%standard_name, state%rpdeldry, pcols, lchnk)
804 :
805 : case ('state%lnpmid')
806 0 : call outfld(state_snapshot(i)%standard_name, state%lnpmid, pcols, lchnk)
807 :
808 : case ('state%lnpmiddry')
809 0 : call outfld(state_snapshot(i)%standard_name, state%lnpmiddry, pcols, lchnk)
810 :
811 : case ('state%exner')
812 0 : call outfld(state_snapshot(i)%standard_name, state%exner, pcols, lchnk)
813 :
814 : case ('state%zm')
815 0 : call outfld(state_snapshot(i)%standard_name, state%zm, pcols, lchnk)
816 :
817 : case ('state%pint')
818 0 : call outfld(state_snapshot(i)%standard_name, state%pint, pcols, lchnk)
819 :
820 : case ('state%pintdry')
821 0 : call outfld(state_snapshot(i)%standard_name, state%pintdry, pcols, lchnk)
822 :
823 : case ('state%lnpint')
824 0 : call outfld(state_snapshot(i)%standard_name, state%lnpint, pcols, lchnk)
825 :
826 : case ('state%lnpintdry')
827 0 : call outfld(state_snapshot(i)%standard_name, state%lnpintdry, pcols, lchnk)
828 :
829 : case ('state%zi')
830 0 : call outfld(state_snapshot(i)%standard_name, state%zi, pcols, lchnk)
831 :
832 : case ('state%te_ini_phys')
833 0 : call outfld(state_snapshot(i)%standard_name, state%te_ini(:, phys_te_idx), pcols, lchnk)
834 :
835 : case ('state%te_cur_phys')
836 0 : call outfld(state_snapshot(i)%standard_name, state%te_cur(:, phys_te_idx), pcols, lchnk)
837 :
838 : case ('state%tw_ini')
839 0 : call outfld(state_snapshot(i)%standard_name, state%tw_ini, pcols, lchnk)
840 :
841 : case ('state%tw_cur')
842 0 : call outfld(state_snapshot(i)%standard_name, state%tw_cur, pcols, lchnk)
843 :
844 : case ('state%te_ini_dyn')
845 0 : call outfld(state_snapshot(i)%standard_name, state%te_ini(:, dyn_te_idx), pcols, lchnk)
846 :
847 : case ('state%te_cur_dyn')
848 0 : call outfld(state_snapshot(i)%standard_name, state%te_cur(:, dyn_te_idx), pcols, lchnk)
849 :
850 : case ('air_composition_cp_or_cv_dycore')
851 : ! this field is not part of physics state (it is in air_composition)
852 : ! but describes the atmospheric thermodynamic state and thus saved within the snapshot
853 0 : call outfld(state_snapshot(i)%standard_name, cp_or_cv_dycore(:,:,lchnk), pcols, lchnk)
854 :
855 : case default
856 0 : call endrun('ERROR in state_snapshot_all_outfld: no match found for '//trim(state_snapshot(i)%ddt_string))
857 :
858 : end select
859 :
860 0 : call cam_history_snapshot_deactivate(trim(state_snapshot(i)%standard_name))
861 :
862 : end do
863 :
864 0 : end subroutine state_snapshot_all_outfld
865 :
866 0 : subroutine cam_snapshot_ptend_outfld(ptend, lchnk)
867 :
868 0 : use constituents, only: cnst_name, cnst_longname
869 : !--------------------------------------------------------
870 : ! This subroutine does the outfld calls for ptend fields.
871 : !--------------------------------------------------------
872 :
873 : type(physics_ptend), intent(in) :: ptend
874 : integer, intent(in) :: lchnk
875 :
876 : integer :: mcnst
877 : character(len=128) :: fname
878 :
879 : !--------------------------------------------------------
880 : ! Add the physics_ptend variables to the output
881 : !--------------------------------------------------------
882 :
883 0 : if (ptend%ls) then
884 0 : call outfld('ptend_s', ptend%s, pcols, lchnk)
885 :
886 0 : call outfld('ptend_hflux_srf', ptend%hflux_srf, pcols, lchnk)
887 :
888 0 : call outfld('ptend_hflux_top', ptend%hflux_top, pcols, lchnk)
889 : end if
890 :
891 0 : if (ptend%lu) then
892 0 : call outfld('ptend_u', ptend%u, pcols, lchnk)
893 :
894 0 : call outfld('ptend_taux_srf', ptend%taux_srf, pcols, lchnk)
895 :
896 0 : call outfld('ptend_taux_top', ptend%taux_top, pcols, lchnk)
897 : end if
898 :
899 0 : if (ptend%lv) then
900 0 : call outfld('ptend_v', ptend%v, pcols, lchnk)
901 :
902 0 : call outfld('ptend_tauy_srf', ptend%tauy_srf, pcols, lchnk)
903 :
904 0 : call outfld('ptend_tauy_top', ptend%tauy_top, pcols, lchnk)
905 : end if
906 :
907 0 : do mcnst = 1, pcnst
908 0 : if (ptend%lq(mcnst)) then
909 0 : fname = 'ptend_'//trim(cnst_name(mcnst))
910 0 : call outfld(trim(fname), ptend%q(:,:,mcnst), pcols, lchnk)
911 :
912 0 : fname = 'ptend_cflx_srf_'//trim(cnst_name(mcnst))
913 0 : call outfld(trim(fname), ptend%cflx_srf(:,mcnst), pcols, lchnk)
914 :
915 0 : fname = 'ptend_cflx_top_'//trim(cnst_name(mcnst))
916 0 : call outfld(trim(fname), ptend%cflx_top(:,mcnst), pcols, lchnk)
917 : end if
918 : end do
919 :
920 :
921 0 : end subroutine cam_snapshot_ptend_outfld
922 :
923 0 : subroutine cnst_snapshot_all_outfld(lchnk, file_num, cnst)
924 :
925 : integer, intent(in) :: lchnk
926 : integer, intent(in) :: file_num
927 : real(r8), intent(in) :: cnst(:,:,:)
928 :
929 : integer :: i
930 :
931 0 : do i=1, ncnst_var
932 :
933 : ! Turn on the writing for only the requested tape (file_num)
934 0 : call cam_history_snapshot_activate(trim(cnst_snapshot(i)%standard_name), file_num)
935 0 : call outfld(cnst_snapshot(i)%standard_name, cnst(:,:,i), pcols, lchnk)
936 :
937 : ! Now that the field has been written, turn off the writing for field
938 0 : call cam_history_snapshot_deactivate(trim(cnst_snapshot(i)%standard_name))
939 :
940 : end do
941 :
942 0 : end subroutine cnst_snapshot_all_outfld
943 :
944 0 : subroutine tend_snapshot_all_outfld(lchnk, file_num, tend)
945 :
946 : integer, intent(in) :: lchnk
947 : integer, intent(in) :: file_num
948 : type(physics_tend), intent(in) :: tend
949 :
950 : integer :: i
951 :
952 0 : do i=1, ntend_var
953 :
954 : ! Turn on the writing for only the requested tape (file_num)
955 0 : call cam_history_snapshot_activate(trim(tend_snapshot(i)%standard_name), file_num)
956 :
957 : ! Select the tend field which is being written
958 : select case(tend_snapshot(i)%ddt_string)
959 :
960 : case ('tend%dtdt')
961 0 : call outfld(tend_snapshot(i)%standard_name, tend%dtdt, pcols, lchnk)
962 :
963 : case ('tend%dudt')
964 0 : call outfld(tend_snapshot(i)%standard_name, tend%dudt, pcols, lchnk)
965 :
966 : case ('tend%dvdt')
967 0 : call outfld(tend_snapshot(i)%standard_name, tend%dvdt, pcols, lchnk)
968 :
969 : case ('tend%flx_net')
970 0 : call outfld(tend_snapshot(i)%standard_name, tend%flx_net, pcols, lchnk)
971 :
972 : case ('tend%te_tnd')
973 0 : call outfld(tend_snapshot(i)%standard_name, tend%te_tnd, pcols, lchnk)
974 :
975 : case ('tend%tw_tnd')
976 0 : call outfld(tend_snapshot(i)%standard_name, tend%tw_tnd, pcols, lchnk)
977 :
978 : case default
979 0 : call endrun('ERROR in tend_snapshot_all_outfld: no match found for '//trim(tend_snapshot(i)%ddt_string))
980 :
981 : end select
982 :
983 0 : call cam_history_snapshot_deactivate(trim(tend_snapshot(i)%standard_name))
984 :
985 : end do
986 :
987 0 : end subroutine tend_snapshot_all_outfld
988 :
989 0 : subroutine cam_in_snapshot_all_outfld(lchnk, file_num, cam_in)
990 :
991 : integer, intent(in) :: lchnk
992 : integer, intent(in) :: file_num
993 : type(cam_in_t), intent(in) :: cam_in
994 :
995 : integer :: i
996 :
997 0 : do i=1, ncam_in_var
998 :
999 : ! Turn on the writing for only the requested tape (file_num)
1000 0 : call cam_history_snapshot_activate(trim(cam_in_snapshot(i)%standard_name), file_num)
1001 :
1002 : ! Select the cam_in field which is being written
1003 : select case(cam_in_snapshot(i)%ddt_string)
1004 :
1005 : case ('cam_in%landfrac')
1006 0 : call outfld(cam_in_snapshot(i)%standard_name, cam_in%landfrac, pcols, lchnk)
1007 : case ('cam_in%ocnfrac')
1008 0 : call outfld(cam_in_snapshot(i)%standard_name, cam_in%ocnfrac, pcols, lchnk)
1009 : case ('cam_in%snowhland')
1010 0 : call outfld(cam_in_snapshot(i)%standard_name, cam_in%snowhland, pcols, lchnk)
1011 : case ('cam_in%ts')
1012 0 : call outfld(cam_in_snapshot(i)%standard_name, cam_in%ts, pcols, lchnk)
1013 : case ('cam_in%sst')
1014 0 : call outfld(cam_in_snapshot(i)%standard_name, cam_in%sst, pcols, lchnk)
1015 : case ('cam_in%icefrac')
1016 0 : call outfld(cam_in_snapshot(i)%standard_name, cam_in%icefrac, pcols, lchnk)
1017 : case ('cam_in%shf')
1018 0 : call outfld(cam_in_snapshot(i)%standard_name, cam_in%shf, pcols, lchnk)
1019 : case ('cam_in%cflx')
1020 0 : call outfld(cam_in_snapshot(i)%standard_name, cam_in%cflx, pcols, lchnk)
1021 : case ('cam_in%wsx')
1022 0 : call outfld(cam_in_snapshot(i)%standard_name, cam_in%wsx, pcols, lchnk)
1023 : case ('cam_in%wsy')
1024 0 : call outfld(cam_in_snapshot(i)%standard_name, cam_in%wsy, pcols, lchnk)
1025 : case ('cam_in%asdif')
1026 0 : call outfld(cam_in_snapshot(i)%standard_name, cam_in%asdif, pcols, lchnk)
1027 : case ('cam_in%aldif')
1028 0 : call outfld(cam_in_snapshot(i)%standard_name, cam_in%aldif, pcols, lchnk)
1029 : case ('cam_in%lwup')
1030 0 : call outfld(cam_in_snapshot(i)%standard_name, cam_in%lwup, pcols, lchnk)
1031 : case ('cam_in%asdir')
1032 0 : call outfld(cam_in_snapshot(i)%standard_name, cam_in%asdir, pcols, lchnk)
1033 : case ('cam_in%aldir')
1034 0 : call outfld(cam_in_snapshot(i)%standard_name, cam_in%aldir, pcols, lchnk)
1035 : case ('cam_in%meganflx')
1036 0 : if (associated (cam_in%meganflx)) &
1037 0 : call outfld(cam_in_snapshot(i)%standard_name, cam_in%meganflx, pcols, lchnk)
1038 : case ('cam_in%fireflx')
1039 0 : if (associated (cam_in%fireflx)) &
1040 0 : call outfld(cam_in_snapshot(i)%standard_name, cam_in%fireflx, pcols, lchnk)
1041 : case ('cam_in%fireztop')
1042 0 : if (associated (cam_in%fireztop)) &
1043 0 : call outfld(cam_in_snapshot(i)%standard_name, cam_in%fireztop, pcols, lchnk)
1044 : case ('cam_in%depvel')
1045 0 : if (associated (cam_in%depvel)) &
1046 0 : call outfld(cam_in_snapshot(i)%standard_name, cam_in%depvel, pcols, lchnk)
1047 : case ('cam_in%lhf')
1048 0 : call outfld(cam_in_snapshot(i)%standard_name, cam_in%lhf, pcols, lchnk)
1049 : case ('cam_in%fv')
1050 0 : if (associated (cam_in%fv)) &
1051 0 : call outfld(cam_in_snapshot(i)%standard_name, cam_in%fv, pcols, lchnk)
1052 : case ('cam_in%ram1')
1053 0 : if (associated (cam_in%ram1)) &
1054 0 : call outfld(cam_in_snapshot(i)%standard_name, cam_in%ram1, pcols, lchnk)
1055 : case ('cam_in%dstflx')
1056 0 : if (associated (cam_in%dstflx)) &
1057 0 : call outfld(cam_in_snapshot(i)%standard_name, cam_in%dstflx, pcols, lchnk)
1058 :
1059 : case default
1060 0 : call endrun('ERROR in cam_in_snapshot_all_outfld: no match found for '//trim(cam_in_snapshot(i)%ddt_string))
1061 :
1062 : end select
1063 :
1064 0 : call cam_history_snapshot_deactivate(trim(cam_in_snapshot(i)%standard_name))
1065 :
1066 : end do
1067 :
1068 0 : end subroutine cam_in_snapshot_all_outfld
1069 :
1070 0 : subroutine cam_out_snapshot_all_outfld(lchnk, file_num, cam_out)
1071 :
1072 : integer, intent(in) :: lchnk
1073 : integer, intent(in) :: file_num
1074 : type(cam_out_t), intent(in) :: cam_out
1075 :
1076 : integer :: i
1077 :
1078 0 : do i=1, ncam_out_var
1079 :
1080 : ! Turn on the writing for only the requested tape (file_num)
1081 0 : call cam_history_snapshot_activate(trim(cam_out_snapshot(i)%standard_name), file_num)
1082 :
1083 : ! Select the cam_out field which is being written
1084 : select case(cam_out_snapshot(i)%ddt_string)
1085 :
1086 : case ('cam_out%precc')
1087 0 : call outfld(cam_out_snapshot(i)%standard_name, cam_out%precc, pcols, lchnk)
1088 :
1089 : case ('cam_out%precl')
1090 0 : call outfld(cam_out_snapshot(i)%standard_name, cam_out%precl, pcols, lchnk)
1091 :
1092 : case ('cam_out%precsc')
1093 0 : call outfld(cam_out_snapshot(i)%standard_name, cam_out%precsc, pcols, lchnk)
1094 :
1095 : case ('cam_out%precsl')
1096 0 : call outfld(cam_out_snapshot(i)%standard_name, cam_out%precsl, pcols, lchnk)
1097 :
1098 : case ('cam_out%nhx_nitrogen_flx')
1099 0 : if (associated(cam_out%nhx_nitrogen_flx)) &
1100 0 : call outfld(cam_out_snapshot(i)%standard_name, cam_out%nhx_nitrogen_flx, pcols, lchnk)
1101 :
1102 : case ('cam_out%noy_nitrogen_flx')
1103 0 : if (associated(cam_out%noy_nitrogen_flx)) &
1104 0 : call outfld(cam_out_snapshot(i)%standard_name, cam_out%noy_nitrogen_flx, pcols, lchnk)
1105 :
1106 : case ('cam_out%bcphodry')
1107 0 : call outfld(cam_out_snapshot(i)%standard_name, cam_out%bcphodry, pcols, lchnk)
1108 :
1109 : case ('cam_out%bcphidry')
1110 0 : call outfld(cam_out_snapshot(i)%standard_name, cam_out%bcphidry, pcols, lchnk)
1111 :
1112 : case ('cam_out%ocphodry')
1113 0 : call outfld(cam_out_snapshot(i)%standard_name, cam_out%ocphodry, pcols, lchnk)
1114 :
1115 : case ('cam_out%ocphidry')
1116 0 : call outfld(cam_out_snapshot(i)%standard_name, cam_out%ocphidry, pcols, lchnk)
1117 :
1118 : case ('cam_out%bcphiwet')
1119 0 : call outfld(cam_out_snapshot(i)%standard_name, cam_out%bcphiwet, pcols, lchnk)
1120 :
1121 : case ('cam_out%ocphiwet')
1122 0 : call outfld(cam_out_snapshot(i)%standard_name, cam_out%ocphiwet, pcols, lchnk)
1123 :
1124 : case ('cam_out%dstwet1')
1125 0 : call outfld(cam_out_snapshot(i)%standard_name, cam_out%dstwet1, pcols, lchnk)
1126 :
1127 : case ('cam_out%dstwet2')
1128 0 : call outfld(cam_out_snapshot(i)%standard_name, cam_out%dstwet2, pcols, lchnk)
1129 :
1130 : case ('cam_out%dstwet3')
1131 0 : call outfld(cam_out_snapshot(i)%standard_name, cam_out%dstwet3, pcols, lchnk)
1132 :
1133 : case ('cam_out%dstwet4')
1134 0 : call outfld(cam_out_snapshot(i)%standard_name, cam_out%dstwet4, pcols, lchnk)
1135 :
1136 : case ('cam_out%dstdry1')
1137 0 : call outfld(cam_out_snapshot(i)%standard_name, cam_out%dstdry1, pcols, lchnk)
1138 :
1139 : case ('cam_out%dstdry2')
1140 0 : call outfld(cam_out_snapshot(i)%standard_name, cam_out%dstdry2, pcols, lchnk)
1141 :
1142 : case ('cam_out%dstdry3')
1143 0 : call outfld(cam_out_snapshot(i)%standard_name, cam_out%dstdry3, pcols, lchnk)
1144 :
1145 : case ('cam_out%dstdry4')
1146 0 : call outfld(cam_out_snapshot(i)%standard_name, cam_out%dstdry4, pcols, lchnk)
1147 :
1148 : case ('cam_out%sols')
1149 0 : call outfld(cam_out_snapshot(i)%standard_name, cam_out%sols, pcols, lchnk)
1150 :
1151 : case ('cam_out%soll')
1152 0 : call outfld(cam_out_snapshot(i)%standard_name, cam_out%soll, pcols, lchnk)
1153 :
1154 : case ('cam_out%solsd')
1155 0 : call outfld(cam_out_snapshot(i)%standard_name, cam_out%solsd, pcols, lchnk)
1156 :
1157 : case ('cam_out%solld')
1158 0 : call outfld(cam_out_snapshot(i)%standard_name, cam_out%solld, pcols, lchnk)
1159 :
1160 : case ('cam_out%flwds')
1161 0 : call outfld(cam_out_snapshot(i)%standard_name, cam_out%flwds, pcols, lchnk)
1162 :
1163 : case ('cam_out%netsw')
1164 0 : call outfld(cam_out_snapshot(i)%standard_name, cam_out%netsw, pcols, lchnk)
1165 :
1166 : case default
1167 0 : call endrun('ERROR in cam_out_snapshot_all_outfld: no match found for '//trim(cam_out_snapshot(i)%ddt_string))
1168 :
1169 : end select
1170 :
1171 0 : call cam_history_snapshot_deactivate(trim(cam_out_snapshot(i)%standard_name))
1172 :
1173 : end do
1174 :
1175 0 : end subroutine cam_out_snapshot_all_outfld
1176 :
1177 0 : subroutine cam_pbuf_snapshot_all_outfld(lchnk, file_num, pbuf)
1178 : use physics_buffer, only: pbuf_is_used
1179 :
1180 : integer, intent(in) :: lchnk
1181 : integer, intent(in) :: file_num
1182 : type(physics_buffer_desc), pointer, intent(in) :: pbuf(:)
1183 :
1184 : integer :: i, pbuf_idx, ndims
1185 0 : real(r8), pointer, dimension(:,:) :: tmpptr2d
1186 0 : real(r8), pointer, dimension(:,:,:) :: tmpptr3d
1187 0 : real(r8), pointer, dimension(:,:,:,:) :: tmpptr4d
1188 0 : real(r8), pointer, dimension(:,:,:,:,:) :: tmpptr5d
1189 :
1190 :
1191 0 : do i=1, npbuf_var
1192 :
1193 0 : pbuf_idx= pbuf_get_index(pbuf_snapshot(i)%ddt_string)
1194 :
1195 0 : if (pbuf_is_used(pbuf(pbuf_idx))) then
1196 : ! Turn on the writing for only the requested tape (file_num)
1197 0 : call cam_history_snapshot_activate(trim(pbuf_snapshot(i)%standard_name), file_num)
1198 :
1199 : ! Retrieve the pbuf data (dependent on the number of dimensions)
1200 0 : ndims = count(pbuf_snapshot(i)%dim_name(:) /= '')
1201 :
1202 0 : select case (ndims) ! Note that dimension 5 and 6 do not work with pbuf_get_field, so these are not used here
1203 :
1204 : case (1)
1205 0 : call pbuf_get_field(pbuf, pbuf_idx, tmpptr2d)
1206 0 : call outfld(pbuf_snapshot(i)%standard_name, tmpptr2d, pcols, lchnk)
1207 :
1208 : case (2)
1209 0 : call pbuf_get_field(pbuf, pbuf_idx, tmpptr3d)
1210 0 : call outfld(pbuf_snapshot(i)%standard_name, tmpptr3d, pcols, lchnk)
1211 :
1212 : case (3)
1213 0 : call pbuf_get_field(pbuf, pbuf_idx, tmpptr3d)
1214 0 : call outfld(pbuf_snapshot(i)%standard_name, tmpptr4d, pcols, lchnk)
1215 :
1216 : case (4)
1217 0 : call pbuf_get_field(pbuf, pbuf_idx, tmpptr5d)
1218 0 : call outfld(pbuf_snapshot(i)%standard_name, tmpptr5d, pcols, lchnk)
1219 :
1220 : end select
1221 :
1222 : ! Now that the field has been written, turn off the writing for field
1223 0 : call cam_history_snapshot_deactivate(trim(pbuf_snapshot(i)%standard_name))
1224 :
1225 :
1226 : end if
1227 :
1228 : end do
1229 :
1230 0 : end subroutine cam_pbuf_snapshot_all_outfld
1231 :
1232 0 : subroutine fill_pbuf_info(pbuf_info, pbuf, const_cname)
1233 :
1234 : !---------------------------------------------------
1235 : ! This subroutine exists to link the pbuf name with units. It can be expanded to include standard_names
1236 : ! at a later date if needed. It is a list of all the pbuf fields that are called within CAM with actual
1237 : ! names.
1238 : !---------------------------------------------------
1239 :
1240 : type(pbuf_info_type), intent(inout) :: pbuf_info(:)
1241 : type(physics_buffer_desc), intent(in) :: pbuf(:)
1242 : character(len=*), intent(in) :: const_cname(:)
1243 :
1244 0 : logical, dimension(size(pbuf)) :: found
1245 : character(len=24), dimension(2,npbuf_all) :: pbuf_all
1246 : character(len=24) :: pbuf_name
1247 : integer :: i, ipbuf
1248 :
1249 0 : found(:) = .false.
1250 :
1251 : pbuf_all(1:2,1:100) = reshape ( (/ &
1252 : 'ACCRE_ENHAN ','unset ',&
1253 : 'ACGCME ','unset ',&
1254 : 'ACLDY_CEN ','unset ',&
1255 : 'ACNUM ','unset ',&
1256 : 'ACPRECL ','unset ',&
1257 : 'AIST ','unset ',&
1258 : 'ALST ','unset ',&
1259 : 'am_evp_st ','unset ',&
1260 : 'AMIE_efxg ','mW/m2 ',&
1261 : 'AMIE_kevg ','keV ',&
1262 : 'AST ','1 ',&
1263 : 'AurIPRateSum ','unset ',&
1264 : 'awk_PBL ','unset ',&
1265 : 'bprod ','unset ',&
1266 : 'CC_ni ','unset ',&
1267 : 'CC_nl ','unset ',&
1268 : 'CC_qi ','unset ',&
1269 : 'CC_ql ','unset ',&
1270 : 'CC_qlst ','unset ',&
1271 : 'CC_qv ','unset ',&
1272 : 'CC_T ','unset ',&
1273 : 'CICEWP ','unset ',&
1274 : 'CLDBOT ','1 ',&
1275 : 'CLDEMIS ','unset ',&
1276 : 'CLDFGRAU ','1 ',&
1277 : 'CLDFSNOW ','1 ',&
1278 : 'CLD ','unset ',&
1279 : 'CLDICEINI ','unset ',&
1280 : 'CLDLIQINI ','unset ',&
1281 : 'CLDO ','unset ',&
1282 : 'CLDTAU ','unset ',&
1283 : 'CLDTOP ','1 ',&
1284 : 'CLIQWP ','unset ',&
1285 : 'CLOUD_FRAC ','unset ',&
1286 : 'CLUBB_BUFFER ','unset ',&
1287 : 'CMELIQ ','kg/kg/s ',&
1288 : 'CMFMC_SH ','unset ',&
1289 : 'cmfr_det ','kg/m2/s ',&
1290 : 'CONCLD ','fraction ',&
1291 : 'CRM_CLD_RAD ','unset ',&
1292 : 'CRM_DGNUMWET ','unset ',&
1293 : 'CRM_NC ','/kg ',&
1294 : 'CRM_NC_RAD ','unset ',&
1295 : 'CRM_NG ','/kg ',&
1296 : 'CRM_NI ','/kg ',&
1297 : 'CRM_NI_RAD ','unset ',&
1298 : 'CRM_NR ','/kg ',&
1299 : 'CRM_NS ','/kg ',&
1300 : 'CRM_NS_RAD ','unset ',&
1301 : 'CRM_QAERWAT ','unset ',&
1302 : 'CRM_QC ','kg/kg ',&
1303 : 'CRM_QC_RAD ','unset ',&
1304 : 'CRM_QG ','kg/kg ',&
1305 : 'CRM_QI ','kg/kg ',&
1306 : 'CRM_QI_RAD ','unset ',&
1307 : 'CRM_QN ','unset ',&
1308 : 'CRM_QP ','kg/kg ',&
1309 : 'CRM_QRAD ','unset ',&
1310 : 'CRM_QR ','kg/kg ',&
1311 : 'CRM_QS ','kg/kg ',&
1312 : 'CRM_QS_RAD ','unset ',&
1313 : 'CRM_QT ','unset ',&
1314 : 'CRM_QV_RAD ','unset ',&
1315 : 'CRM_T ',' K ',&
1316 : 'CRM_T_RAD ','unset ',&
1317 : 'CRM_U ','m/s ',&
1318 : 'CRM_V ','m/s ',&
1319 : 'CRM_W ','m/s ',&
1320 : 'CT ','unset ',&
1321 : 'cu_cmfr ','kg/m2/s ',&
1322 : 'cuorg ','unset ',&
1323 : 'cu_qir ','kg/kg ',&
1324 : 'cu_qlr ','kg/kg ',&
1325 : 'cu_qtr ','kg/kg ',&
1326 : 'cushavg ','m ',&
1327 : 'cush ','m ',&
1328 : 'cu_thlr ','K ',&
1329 : 'cu_trr ','unset ',&
1330 : 'cu_ur ','m/s ',&
1331 : 'cu_vr ','m/s ',&
1332 : 'CV_REFFICE ','micron ',&
1333 : 'CV_REFFLIQ ','micron ',&
1334 : 'DEGRAU ','unset ',&
1335 : 'DEI ','unset ',&
1336 : 'delta_qt_PBL ','unset ',&
1337 : 'delta_thl_PBL ','unset ',&
1338 : 'delta_tr_PBL ','unset ',&
1339 : 'delta_u_PBL ','unset ',&
1340 : 'delta_v_PBL ','unset ',&
1341 : 'DES ','unset ',&
1342 : 'DGNUM ','unset ',&
1343 : 'DGNUMWET ','unset ',&
1344 : 'DIFZM ','kg/kg/s ',&
1345 : 'DLFZM ','kg/kg/s ',&
1346 : 'DNIFZM ','1/kg/s ',&
1347 : 'DNLFZM ','1/kg/s ',&
1348 : 'DP_FLXPRC ','unset ',&
1349 : 'DP_FLXSNW ','unset ',&
1350 : 'DP_FRAC ','unset ',&
1351 0 : 'dragblj ','1/s ' /), (/2,100/))
1352 :
1353 : pbuf_all(1:2,101:200) = reshape ( (/ &
1354 : 'DRYMASS ','unset ',&
1355 : 'DRYRAD ','unset ',&
1356 : 'DRYVOL ','unset ',&
1357 : 'DTCORE ','K/s ',&
1358 : 'evprain_st ','unset ',&
1359 : 'evpsnow_st ','unset ',&
1360 : 'FICE ','fraction ',&
1361 : 'FLNS ','W/m2 ',&
1362 : 'FLNT ','W/m2 ',&
1363 : 'FRACIS ','unset ',&
1364 : 'FRACSOA ','unset ',&
1365 : 'FRACSOG ','unset ',&
1366 : 'FRONTGA ','unset ',&
1367 : 'FRONTGF ','K^2/M^2/S ',&
1368 : 'FRZCNT ','unset ',&
1369 : 'FRZDEP ','unset ',&
1370 : 'FRZIMM ','unset ',&
1371 : 'FSDS ','W/m2 ',&
1372 : 'FSNS ','W/m2 ',&
1373 : 'FSNT ','W/m2 ',&
1374 : 'HallConduct ','unset ',&
1375 : 'HYGRO ','unset ',&
1376 : 'ICCWAT ','unset ',&
1377 : 'ICGRAUWP ','unset ',&
1378 : 'ICIWP ','unset ',&
1379 : 'ICIWPST ','unset ',&
1380 : 'ICLWP ','unset ',&
1381 : 'ICLWPST ','unset ',&
1382 : 'ICSWP ','unset ',&
1383 : 'ICWMRDP ','kg/kg ',&
1384 : 'ICWMRSH ','kg/kg ',&
1385 : 'IonRates ','unset ',&
1386 : 'ipbl ','unset ',&
1387 : 'ISS_FRAC ','unset ',&
1388 : 'kpblh ','unset ',&
1389 : 'ksrftms ','unset ',&
1390 : 'kvh ','m2/s ',&
1391 : 'kvm ','m2/s ',&
1392 : 'kvt ','m2/s ',&
1393 : 'LAMBDAC ','unset ',&
1394 : 'LANDM ','unset ',&
1395 : 'LCWAT ','unset ',&
1396 : 'LD ','unset ',&
1397 : 'LHFLX ','W/m2 ',&
1398 : 'LHFLX_RES ','unset ',&
1399 : 'LS_FLXPRC ','kg/m2/s ',&
1400 : 'LS_FLXSNW ','kg/m2/s ',&
1401 : 'LS_MRPRC ','unset ',&
1402 : 'LS_MRSNW ','unset ',&
1403 : 'LS_REFFRAIN ','micron ',&
1404 : 'LS_REFFSNOW ','micron ',&
1405 : 'LU ','unset ',&
1406 : 'MAMH2SO4EQ ','unset ',&
1407 : 'MU ','Pa/s ',&
1408 : 'NAAI_HOM ','unset ',&
1409 : 'NAAI ','unset ',&
1410 : 'NACON ','unset ',&
1411 : 'NAER ','unset ',&
1412 : 'NEVAPR_DPCU ','unset ',&
1413 : 'NEVAPR ','unset ',&
1414 : 'NEVAPR_SHCU ','unset ',&
1415 : 'NIWAT ','unset ',&
1416 : 'NLWAT ','unset ',&
1417 : 'NMXRGN ','unset ',&
1418 : 'NPCCN ','unset ',&
1419 : 'NRAIN ','m-3 ',&
1420 : 'NSNOW ','m-3 ',&
1421 : 'O3 ','unset ',&
1422 : 'pblh ','m ',&
1423 : 'PDF_PARAMS ','unset ',&
1424 : 'PDF_PARAMS_ZM ','unset ',&
1425 : 'PedConduct ','unset ',&
1426 : 'PMXRGN ','unset ',&
1427 : 'PRAIN ','unset ',&
1428 : 'PREC_DP ','unset ',&
1429 : 'PREC_PCW ','m/s ',&
1430 : 'PREC_SED ','unset ',&
1431 : 'PREC_SH ','unset ',&
1432 : 'PREC_SH ','unset ',&
1433 : 'PREC_STR ','unset ',&
1434 : 'PRER_EVAP ','unset ',&
1435 : 'PSL ','Pa ',&
1436 : 'QAERWAT ','unset ',&
1437 : 'QCWAT ','unset ',&
1438 : 'QFLX ','kg/m2/s ',&
1439 : 'QFLX_RES ','unset ',&
1440 : 'QINI ','unset ',&
1441 : 'qir_det ','kg/kg ',&
1442 : 'QIST ','unset ',&
1443 : 'qlr_det ','kg/kg ',&
1444 : 'QLST ','unset ',&
1445 : 'QME ','unset ',&
1446 : 'qpert ','kg/kg ',&
1447 : 'QRAIN ','kg/kg ',&
1448 : 'QRL ','K/s ',&
1449 : 'qrlin ','unset ',&
1450 : 'QRS ','K/s ',&
1451 : 'qrsin ','unset ',&
1452 : 'QSATFAC ','- ',&
1453 0 : 'QSNOW ','kg/kg ' /), (/2,100/))
1454 :
1455 : pbuf_all(1:2,201:300) = reshape ( (/ &
1456 : 'QTeAur ','unset ',&
1457 : 'qti_flx ','unset ',&
1458 : 'qtl_flx ','unset ',&
1459 : 'RAD_CLUBB ','unset ',&
1460 : 'RATE1_CW2PR_ST ','unset ',&
1461 : 'RCM ','unset ',&
1462 : 'RE_ICE ','unset ',&
1463 : 'REI ','micron ',&
1464 : 'RELHUM ','percent ',&
1465 : 'REL ','micron ',&
1466 : 'RELVAR ','- ',&
1467 : 'RNDST ','unset ',&
1468 : 'RPRDDP ','unset ',&
1469 : 'RPRDSH ','unset ',&
1470 : 'RPRDTOT ','unset ',&
1471 : 'RTM ','unset ',&
1472 : 'rtp2_mc_zt ','unset ',&
1473 : 'RTP2_nadv ','unset ',&
1474 : 'rtpthlp_mc_zt ','unset ',&
1475 : 'RTPTHLP_nadv ','unset ',&
1476 : 'RTPTHVP ','unset ',&
1477 : 'SADICE ','cm2/cm3 ',&
1478 : 'SADSNOW ','cm2/cm3 ',&
1479 : 'SADSULF ','unset ',&
1480 : 'SD ','unset ',&
1481 : 'SGH30 ','unset ',&
1482 : 'SGH ','unset ',&
1483 : 'SH_CLDICE ','unset ',&
1484 : 'SH_CLDLIQ ','unset ',&
1485 : 'SH_E_ED_RATIO ','unset ',&
1486 : 'SHFLX ','W/m2 ',&
1487 : 'SH_FLXPRC ','unset ',&
1488 : 'SHFLX_RES ','unset ',&
1489 : 'SH_FLXSNW ','unset ',&
1490 : 'SH_FRAC ','unset ',&
1491 : 'shfrc ','unset ',&
1492 : 'SNOW_DP ','unset ',&
1493 : 'SNOW_PCW ','unset ',&
1494 : 'SNOW_SED ','unset ',&
1495 : 'SNOW_SH ','unset ',&
1496 : 'SNOW_STR ','unset ',&
1497 : 'SO4DRYVOL ','unset ',&
1498 : 'SSLTA ','kg/kg ',&
1499 : 'SSLTC ','kg/kg ',&
1500 : 'SU ','unset ',&
1501 : "taubljx ",'N/m2 ',&
1502 : "taubljy ",'N/m2 ',&
1503 : 'tauresx ','unset ',&
1504 : 'tauresy ','unset ',&
1505 : "tautmsx ",'N/m2 ',&
1506 : "tautmsy ",'N/m2 ',&
1507 : 'TAUX ','N/m2 ',&
1508 : 'TAUX_RES ','unset ',&
1509 : 'TAUY ','N/m2 ',&
1510 : 'TAUY_RES ','unset ',&
1511 : 'tcorr ','unset ',&
1512 : 'TCWAT ','unset ',&
1513 : 'TElec ','K ',&
1514 : 'TEOUT ','J/m2 ',&
1515 : 'THLM ','unset ',&
1516 : 'thlp2_mc_zt ','unset ',&
1517 : 'THLP2_nadv ','unset ',&
1518 : 'THLPTHVP ','unset ',&
1519 : 'TIon ','K ',&
1520 : 'TK_CRM ','unset ',&
1521 : 'tke ','m2/s2 ',&
1522 : 'tkes ','m2/s2 ',&
1523 : 'TND_NSNOW ','unset ',&
1524 : 'TND_QSNOW ','unset ',&
1525 : 'tpert ','K ',&
1526 : 'TREFMNAV ','K ',&
1527 : 'TREFMXAV ','K ',&
1528 : 'tropp ','unset ',&
1529 : 'TSTCPY_SCOL ','unset ',&
1530 : 'TTEND_DP ','unset ',&
1531 : 'TTEND_SH ','unset ',&
1532 : 'T_TTEND ','unset ',&
1533 : "UI ",'m/s ',&
1534 : 'UM ','unset ',&
1535 : 'UP2_nadv ','unset ',&
1536 : 'UPWP ','m^2/s^2 ',&
1537 : 'UZM ','M/S ',&
1538 : 'VI ','m/s ',&
1539 : 'VM ','m/s ',&
1540 : 'VOLC_MMR ','unset ',&
1541 : 'VOLC_RAD_GEOM ','unset ',&
1542 : 'VP2_nadv ','unset ',&
1543 : 'VPWP ','m^2/s^2 ',&
1544 : 'went ','m/s ',&
1545 : 'WETDENS_AP ','unset ',&
1546 : "WI ",'m/s ',&
1547 : 'WP3_nadv ','unset ',&
1548 : 'wprtp_mc_zt ','unset ',&
1549 : 'WPRTP_nadv ','unset ',&
1550 : 'wpthlp_mc_zt ','unset ',&
1551 : 'WPTHLP_nadv ','unset ',&
1552 : 'WPTHVP ','unset ',&
1553 : 'WSEDL ','unset ',&
1554 : 'wstarPBL ','unset ',&
1555 0 : 'ZM_DP ','unset ' /), (/2,100/))
1556 :
1557 : pbuf_all(1:2,301:npbuf_all) = reshape ( (/ &
1558 : 'ZM_DSUBCLD ','unset ',&
1559 : 'ZM_DU ','unset ',&
1560 : 'ZM_ED ','unset ',&
1561 : 'ZM_EU ','unset ',&
1562 : 'ZM_IDEEP ','unset ',&
1563 : 'ZM_JT ','unset ',&
1564 : 'ZM_MAXG ','unset ',&
1565 : 'ZM_MD ','unset ',&
1566 : 'ZM_MU ','unset ',&
1567 0 : 'ZTODT ','unset ' /), (/2,10/))
1568 :
1569 : ! Fields which are added with pbuf_add_field calls, but are data driven. These are not
1570 : ! included in the above list. This means that these fields will not have proper units
1571 : ! set for them
1572 : ! 'CG' // shortname, 'unset', &
1573 : ! 'CI' // shortname, 'unset', &
1574 : ! 'CL' // shortname, 'unset', &
1575 : ! ghg_names(i), 'unset', &
1576 : ! mmr_name1, 'unset', &
1577 : ! mmr_name2, 'unset', &
1578 : ! mmr_name3, 'unset', &
1579 : ! mmr_name, 'unset', &
1580 : ! ozone_name, 'unset', &
1581 : ! pbufname, 'unset', &
1582 : ! pbufname, 'unset', &
1583 : ! pbuf_names(i), 'unset', &
1584 : ! rad_name1, 'unset', &
1585 : ! rad_name2, 'unset', &
1586 : ! rad_name3, 'unset', &
1587 : ! rad_name, 'unset', &
1588 : ! sad_name, 'cm2/cm3', &
1589 : ! volcaero_name, 'kg/kg', &
1590 : ! volcrad_name, 'm', &
1591 : ! xname_massptrcw(l, 'unset', &
1592 : ! xname_numptrcw, 'unset', &
1593 : ! aero_names(mm)
1594 : ! cnst_names(iconst)
1595 :
1596 0 : do ipbuf = 1, size(pbuf)
1597 0 : pbuf_name = pbuf_get_field_name(ipbuf)
1598 0 : i = 1
1599 0 : do while ((i <= npbuf_all) .and. .not. found(ipbuf))
1600 0 : if (trim(pbuf_all(1,i)) == trim(pbuf_name)) then
1601 0 : pbuf_info(ipbuf)%name = trim(pbuf_all(1,i))
1602 0 : pbuf_info(ipbuf)%standard_name = 'pbuf_'//trim(pbuf_all(1,i))
1603 0 : pbuf_info(ipbuf)%units = trim(pbuf_all(2,i))
1604 0 : pbuf_info(ipbuf)%dim_string(:) = ' '
1605 0 : found(ipbuf) = .true.
1606 : end if
1607 0 : i = i+1
1608 : end do
1609 0 : if (.not. found(ipbuf)) then
1610 :
1611 : i = 1
1612 : ! Check if variable is a variation of constituent - then use the same units
1613 0 : do while ((i <= ncnst_var) .and. .not. found(ipbuf))
1614 0 : if (trim(const_cname(i)) == trim(pbuf_name)) then
1615 0 : pbuf_info(ipbuf) = pbuf_info_type(trim(const_cname(i)),trim('pbuf_'//const_cname(i)),&
1616 0 : trim(cnst_snapshot(i)%units), ' ')
1617 0 : found(ipbuf) = .true.
1618 : end if
1619 0 : i = i+1
1620 : end do
1621 : end if
1622 :
1623 : ! Found a pbuf that has not been added to this routine
1624 0 : if (.not. found(ipbuf)) then
1625 0 : write(iulog,*) 'WARNING - no units information for: '//trim(pbuf_name)
1626 :
1627 0 : pbuf_info(ipbuf)%name = trim(pbuf_name)
1628 0 : pbuf_info(ipbuf)%standard_name = 'pbuf_'//trim(pbuf_name)
1629 0 : pbuf_info(ipbuf)%units = 'unset'
1630 0 : pbuf_info(ipbuf)%dim_string(:) = ' '
1631 0 : found(ipbuf) = .true.
1632 : end if
1633 :
1634 : end do
1635 :
1636 0 : end subroutine fill_pbuf_info
1637 :
1638 0 : end module cam_snapshot_common
|