275 type(model_state_type),
target,
intent(inout) :: current_state
277 integer :: k, i, iq_tmp, km1, kp1, icol, jcol
281 , thprime_w_local, qprime_w_local
284 icol=current_state%column_local_x
285 jcol=current_state%column_local_y
287 if (current_state%first_timestep_column)
then
288 u_wind_tot(:) = 0.0_default_precision
289 if (
allocated(uprime_tot)) uprime_tot(:) = 0.0_default_precision
290 if (
allocated(uprime)) uprime(:) = 0.0_default_precision
291 v_wind_tot(:) = 0.0_default_precision
292 if (
allocated(vprime_tot)) vprime_tot(:) = 0.0_default_precision
293 if (
allocated(vprime)) vprime(:) = 0.0_default_precision
294 if (
allocated(wke_tot)) wke_tot(:) = 0.0_default_precision
296 w_wind_tot(:) = 0.0_default_precision
297 ww_tot(:) = 0.0_default_precision
298 wwww_tot(:) = 0.0_default_precision
299 www_tot(:) = 0.0_default_precision
300 uw_tot(:) = 0.0_default_precision
301 vw_tot(:) = 0.0_default_precision
302 uv_tot(:) = 0.0_default_precision
304 if (current_state%th%active)
then
305 wtheta_ad_tot(:) = 0.0_default_precision
306 wtheta_cn_tot(:) = 0.0_default_precision
307 th2_tot(:) = 0.0_default_precision
308 theta_tot(:)=0.0_default_precision
310 if (.not. current_state%passive_q .and. &
311 current_state%number_q_fields .gt. 0)
then
312 q_temp(:)=0.0_default_precision
313 qv_tot(:)=0.0_default_precision
314 ql_tot(:)=0.0_default_precision
315 wqv_cn_tot(:)=0.0_default_precision
316 wqv_ad_tot(:)=0.0_default_precision
317 wql_cn_tot(:)=0.0_default_precision
318 wql_ad_tot(:)=0.0_default_precision
319 if (current_state%th%active) &
320 rh_tot(:) = 0.0_default_precision
322 qr_tot(:) = 0.0_default_precision
323 wqr_cn_tot(:) = 0.0_default_precision
324 wqr_ad_tot(:) = 0.0_default_precision
327 qi_tot(:) = 0.0_default_precision
328 wqi_cn_tot(:) = 0.0_default_precision
329 wqi_ad_tot(:) = 0.0_default_precision
332 qs_tot(:) = 0.0_default_precision
333 wqs_cn_tot(:) = 0.0_default_precision
334 wqs_ad_tot(:) = 0.0_default_precision
337 qg_tot(:) = 0.0_default_precision
338 wqg_cn_tot(:) = 0.0_default_precision
339 wqg_ad_tot(:) = 0.0_default_precision
342 if (
allocated(cloud_mask)) cloud_mask(:,:,:) = 0.0_default_precision
343 cloud_mask_tot(:) = 0.0_default_precision
344 cloud_liq_mask_tot(:) = 0.0_default_precision
345 cloud_ice_mask_tot(:) = 0.0_default_precision
350 if (.not. current_state%halo_column)
then
352 do k=1, current_state%local_grid%size(z_index)
353 u_wind_tot(k) = u_wind_tot(k) + &
354 (current_state%u%data(k,jcol,icol) &
355 + current_state%ugal)
356 if (
allocated(uprime_tot))
then
358 (current_state%u%data(k, jcol, icol) &
359 - (current_state%global_grid%configuration%vertical%olubar(k) - current_state%ugal))
363 uprime_tot(k) = uprime_tot(k) + uprime(k)**2.0_default_precision
365 v_wind_tot(k) = v_wind_tot(k) + &
366 (current_state%v%data(k,jcol,icol) &
367 + current_state%vgal)
368 if (
allocated(vprime_tot))
then
370 (current_state%v%data(k, jcol, icol) &
371 - (current_state%global_grid%configuration%vertical%olvbar(k) - current_state%vgal))
375 vprime_tot(k) = vprime_tot(k) + vprime(k)**2.0_default_precision
381 if (trim(advect_flow) .eq.
"pw")
then
382 ww_tot(:) = ww_tot(:) + &
383 (current_state%w%data(:,jcol,icol)**2.)
384 else if (trim(advect_flow) .eq.
"tvd")
then
385 do k=2, current_state%local_grid%size(z_index)
386 ww_tot(k) = ww_tot(k) + 0.5 * &
387 ((current_state%w%data(k-1,jcol,icol) + current_state%w%data(k,jcol,icol)) * &
388 tvd_dgs_terms%adv_w_dgs(k,jcol,icol))
392 do k=2, current_state%local_grid%size(z_index)
393 www_tot(k) = www_tot(k) + &
394 (current_state%w%data(k,jcol,icol)**3.)
395 wwww_tot(k) = wwww_tot(k) + &
396 (current_state%w%data(k,jcol,icol)**4.)
397 w_wind_tot(k) = w_wind_tot(k) + &
398 (current_state%w%data(k,jcol,icol))
403 if (trim(advect_flow) .eq.
"pw")
then
404 do k=1, current_state%local_grid%size(z_index)-1
406 0.25 * ( current_state%u%data(k,jcol,icol) + &
407 current_state%u%data(k,jcol,icol-1) + &
408 current_state%u%data(k+1,jcol,icol) + &
409 current_state%u%data(k+1,jcol,icol-1) ) + &
411 if (
allocated(current_state%global_grid%configuration%vertical%olubar)) &
412 uprime_w_local = uprime_w_local - &
413 0.5 * ( current_state%global_grid%configuration%vertical%olubar(k) + &
414 current_state%global_grid%configuration%vertical%olubar(k+1) )
415 uw_tot(k) = uw_tot(k) + uprime_w_local * &
416 current_state%w%data(k,jcol,icol)
418 else if (trim(advect_flow) .eq.
"tvd")
then
419 do k=2, current_state%local_grid%size(z_index)-1
420 uw_tot(k) = uw_tot(k) + 0.5 * ( &
421 (current_state%w%data(k,jcol,icol) + current_state%w%data(k,jcol,icol+1)) * &
422 tvd_dgs_terms%adv_u_dgs(k+1,jcol,icol))
426 if (trim(advect_flow) .eq.
"pw")
then
427 do k=1, current_state%local_grid%size(z_index)-1
429 0.25 * ( current_state%v%data(k,jcol,icol) + &
430 current_state%v%data(k,jcol-1,icol) + &
431 current_state%v%data(k+1,jcol,icol) + &
432 current_state%v%data(k+1,jcol-1,icol) ) + &
434 if (
allocated(current_state%global_grid%configuration%vertical%olvbar)) &
435 vprime_w_local = vprime_w_local - &
436 0.5 * ( current_state%global_grid%configuration%vertical%olvbar(k) + &
437 current_state%global_grid%configuration%vertical%olvbar(k+1) )
438 vw_tot(k) = vw_tot(k) + vprime_w_local * &
439 current_state%w%data(k,jcol,icol)
441 else if (trim(advect_flow) .eq.
"tvd")
then
442 do k=2, current_state%local_grid%size(z_index)-1
443 vw_tot(k) = vw_tot(k) + 0.5 * ( &
444 (current_state%w%data(k,jcol,icol) + current_state%w%data(k,jcol+1,icol)) * &
445 tvd_dgs_terms%adv_v_dgs(k+1,jcol,icol))
449 if (
allocated(current_state%global_grid%configuration%vertical%olvbar) .and. &
450 allocated(current_state%global_grid%configuration%vertical%olubar))
then
454 do k=1, current_state%local_grid%size(z_index)-1
455 uv_tot(k) = uv_tot(k) + 0.25 * uprime(k) * (vprime(k) &
456 + (current_state%v%data(k,jcol,icol+1)) &
458 + (current_state%v%data(k,jcol-1,icol) &
459 - (current_state%global_grid%configuration%vertical%olvbar(k) - current_state%vgal)) &
460 + (current_state%v%data(k,jcol-1,icol+1)))
464 if (
allocated(wke_tot))
then
465 do k=1, current_state%local_grid%size(z_index)
466 kp1=min(k+1,current_state%local_grid%size(z_index))
468 wke_tot(k) = wke_tot(k) + 0.25_default_precision * ( &
469 current_state%global_grid%configuration%vertical%rho(k) * &
470 ( (current_state%v%data(k,jcol,icol) &
471 + current_state%v%data(k,jcol,icol+1)) &
472 * uprime(k)*uprime(kp1) &
473 + (current_state%v%data(k,jcol,icol) &
474 + current_state%v%data(k,jcol+1,icol)) &
475 * vprime(k) * vprime(kp1) ) &
476 + 0.5_default_precision * ( &
477 (current_state%w%data(k,jcol,icol) &
478 + current_state%w%data(kp1,jcol,icol)) &
479 * current_state%w%data(k,jcol,icol) &
480 * current_state%w%data(kp1,jcol,icol) &
481 * current_state%global_grid%configuration%vertical%rhon(kp1) &
482 +(current_state%w%data(k,jcol,icol) &
483 + current_state%w%data(km1,jcol,icol)) &
484 * current_state%w%data(k,jcol,icol) &
485 * current_state%w%data(km1,jcol,icol) &
486 * current_state%global_grid%configuration%vertical%rhon(k) ) &
491 if (current_state%th%active)
then
492 do k=1, current_state%local_grid%size(z_index)
493 theta_tot(k) = theta_tot(k) + &
494 (current_state%th%data(k,jcol,icol) &
495 + current_state%global_grid%configuration%vertical%thref(k))
496 th2_tot(k) = th2_tot(k) + &
497 (current_state%th%data(k,jcol,icol) - &
498 current_state%global_grid%configuration%vertical%olthbar(k) )**2
505 if (trim(advect_theta) .eq.
"pw")
then
506 do k=1, current_state%local_grid%size(z_index)-1
507 thprime_w_local = 0.5 * ( &
508 current_state%th%data(k,jcol,icol) + &
509 current_state%th%data(k+1,jcol,icol) )
510 wtheta_ad_tot(k) = wtheta_ad_tot(k) + &
511 (current_state%w%data(k,jcol,icol) * &
513 wtheta_cn_tot(k) = wtheta_cn_tot(k)
515 else if (trim(advect_theta) .eq.
"tvd")
then
516 do k=2, current_state%local_grid%size(z_index)-1
517 thprime_w_local = 0.5 * ( &
518 current_state%th%data(k,jcol,icol) + &
519 current_state%th%data(k+1,jcol,icol) )
520 wtheta_cn_tot(k) = wtheta_cn_tot(k) + &
521 current_state%w%data(k,jcol,icol) * &
523 wtheta_ad_tot(k) = wtheta_ad_tot(k) + &
524 current_state%w%data(k,jcol,icol) * &
525 tvd_dgs_terms%adv_th_dgs(k+1,jcol,icol)
530 if (.not. current_state%passive_q .and. current_state%number_q_fields .gt. 0)
then
531 qv_tot(:) = qv_tot(:) + (current_state%q(iqv)%data(:,jcol,icol))
532 ql_tot(:) = ql_tot(:) + (current_state%q(iql)%data(:,jcol,icol))
533 if (current_state%th%active)
then
535 do k=1, current_state%local_grid%size(z_index)
536 exner = current_state%global_grid%configuration%vertical%rprefrcp(k)
537 pmb = (current_state%global_grid%configuration%vertical%prefn(k)/100.)
538 qv = current_state%q(iqv)%data(k, jcol,icol)
539 qc = current_state%q(iql)%data(k, jcol,icol)
540 tdegk = (current_state%th%data(k,jcol,icol) &
541 + current_state%global_grid%configuration%vertical%thref(k))*exner
542 qs = qsaturation(tdegk, pmb)
543 rh_tot(k) = rh_tot(k) + (qv/qs)
548 qr_tot(:) = qr_tot(:) + (current_state%q(iqr)%data(:,jcol,icol))
550 qi_tot(:) = qi_tot(:) + (current_state%q(iqi)%data(:,jcol,icol))
552 qs_tot(:) = qs_tot(:) + (current_state%q(iqs)%data(:,jcol,icol))
554 qg_tot(:) = qg_tot(:) + (current_state%q(iqg)%data(:,jcol,icol))
558 call calculate_wq(current_state, jcol, icol, iqv, wqv_cn_tot, wqv_ad_tot, advect_q)
560 call calculate_wq(current_state, jcol, icol, iql , wql_cn_tot, wql_ad_tot, advect_q)
563 call calculate_wq(current_state, jcol, icol, iqr, wqr_cn_tot, wqr_ad_tot, advect_q)
566 call calculate_wq(current_state, jcol, icol, iqi, wqi_cn_tot, wqi_ad_tot, advect_q)
569 call calculate_wq(current_state, jcol, icol, iqs, wqs_cn_tot, wqs_ad_tot, advect_q)
572 call calculate_wq(current_state, jcol, icol, iqg, wqg_cn_tot, wqg_ad_tot, advect_q)
575 call calculate_cloud_mask(current_state, jcol, icol)